我在脚本nohupssh.sh中有一个简单的远程ssh命令
sleep 30
ssh -v -l developer server11 "/usr/local/jdk1.7.0_45/bin/jmap -histo:live 1770;"我按如下方式运行该脚本:
nohup nohupssh.sh > out.log 2>&1 & 当我如上所示执行它时,jmap实用程序就可以在远程服务器上成功执行。但是,如果我按照上面所示执行它并退出bash shell,我会得到如下所示的错误。
请注意,我在本地和远程服务器中都有一个格式正确的authorized_keys。还要注意,这两个服务器中都没有id_rsa,因为这些服务器是共享的。
我尝试了很多组合:
ssh -v -A -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o GlobalKnownHostsFile=/dev/null server11 .... 但无济于事。为了寻找线索,我仔细查看了ssh的手册页,尝试了各种方法。我假设一定有一个或一组ssh选项可以解决这个问题。真正的脚本(而不是上面删节的脚本)也有scp。因此,我希望我所回避的选项能够同时适用于scp和ssh。
完整的详细日志为
OpenSSH_4.3p2, OpenSSL 0.9.8e-fips-rhel5 01 Jul 2008
debug1: Reading configuration data /home/developer/.ssh/config
debug1: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to server11 [10.255.10.20] port 22.
debug1: fd 4 clearing O_NONBLOCK
debug1: Connection established.
debug1: identity file /home/developer/.ssh/identity type -1
debug1: identity file /home/developer/.ssh/id_rsa type -1
debug1: identity file /home/developer/.ssh/id_dsa type -1
debug1: loaded 3 keys
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.3
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
Warning: Permanently added 'server11,10.255.10.20' (RSA) to the list of known hosts.
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
****************************************************************************
WARNING: Unauthorized access to this system is forbidden and will be
prosecuted by law. By accessing this system, you agree that your
actions may be monitored.
****************************************************************************
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/developer/.ssh/identity
debug1: Trying private key: /home/developer/.ssh/id_rsa
debug1: Trying private key: /home/developer/.ssh/id_dsa
debug1: Next authentication method: password
debug1: read_passphrase: can't open /dev/tty: No such device or address
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
debug1: Authentications that can continue: publickey,password
Permission denied, please try again.
debug1: read_passphrase: can't open /dev/tty: No such device or address
ssh_askpass: exec(/usr/libexec/openssh/ssh-askpass): No such file or directory
debug1: Authentications that can continue: publickey,password
debug1: No more authentication methods to try.
Permission denied (publickey,password).发布于 2015-07-14 18:53:11
从错误日志中:
可以继续的
身份验证:公钥、密码
由于您没有设置公钥("there is NO id_rsa"),您需要输入密码才能访问远程服务器,但是您已经断开了标准输入:
read_passphrase:无法打开/dev/tty:没有这样的设备或地址
SSH不是很容易被黑客自动输入密码,所以如果你不能在上面放一个id_rsa,你最好的办法就是在输入远程服务器的密码后进行后台和分离。尝试^Z:
运行nohup nohupssh.sh > out.log 2>&1
bg %1
发布于 2021-03-16 09:04:13
当我的私钥格式错误时-而不是许多行,而是作为一行程序传递,您可能会遇到任何其他格式问题,如开头或结尾处忘记的"-“,或行尾的错误,如缺少换行符格式或行尾的附加字母。我遇到了这个read_passphrase: can't open /dev/tty错误。
有关更多细节,请参阅Dockerfile: clone repo with passwordless private key. Errors: “authentication agent” or “read_passphrase: can't open /dev/tty”,其主要思想来自Add private key to ssh-agent in docker file,它的想法也来自Gitlab CI/Docker: ssh-add keeps asking for passphrase。
https://stackoverflow.com/questions/22829291
复制相似问题