首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有密码保护的SSH密钥的并行SSH

具有密码保护的SSH密钥的并行SSH
EN

Unix & Linux用户
提问于 2014-05-12 00:42:27
回答 1查看 21.3K关注 0票数 8

在使用parallel-ssh (和相关工具)执行任务时,我希望使用受密码保护的SSH密钥。但是,我不能让它起作用。

所有关于parallel-ssh的文档都表明,我应该能够使用--askpass-A来完成以下操作:

代码语言:javascript
复制
-A
--askpass
      Prompt  for  a  password  and pass it to ssh.  The password may be 
      used for either to unlock a key or for password authentication.  The 
      password is transferred in a fairly secure manner (e.g., it will not 
      show up in argument lists).  However, be aware that a root user on 
      your system could potentially intercept the password.

但是,当我输入密钥的密码时,它不起作用:

代码语言:javascript
复制
$ parallel-ssh --hosts=machines --user=my_user --askpass \
    --timeout=0 --inline -v 'sudo apt-get update'
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password: 
[1] 09:59:36 [FAILURE] amritiii Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[2] 09:59:37 [FAILURE] gbdev Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[3] 09:59:37 [FAILURE] code Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[4] 09:59:37 [FAILURE] apollo Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[5] 09:59:37 [FAILURE] odin Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[6] 09:59:37 [FAILURE] hathor Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[7] 09:59:37 [FAILURE] ldap Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[8] 09:59:37 [FAILURE] thor Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).
[9] 09:59:37 [FAILURE] bioserver Exited with error code 255
Stderr: Enter passphrase for key '/home/nhaigh/.ssh/id_rsa': 
Permission denied (publickey,password).

我已经确认我的SSH密钥和密码在每台机器上都能工作,所以我不知道如何工作。

EN

回答 1

Unix & Linux用户

回答已采纳

发布于 2014-05-12 01:42:44

假设parallel-sshpssh是等价的,那么是的,在使用-A开关时,您想要做的事情应该可以很好地传递密码。

示例

下面是我连接到两个不同系统( host1host2 )的例子。我使用-l切换到pssh来提供root的默认用户。但是,在host2上,我通过将主机名指定为user1@host2来覆盖-H开关中的此内容。

代码语言:javascript
复制
$ pssh -A -i -H "host1 user1@host2" -l root 'echo "hi"'
Warning: do not enter your password if anyone else has superuser
privileges or access to your account.
Password: 
[1] 21:38:00 [SUCCESS] user1@host2
hi
Stderr: 
This is a private site.  Unauthorized connections are prohibited.  
All activity may be logged.  Disconnect immediately if you object to 
this policy or are not an authorized user.

X11 forwarding request failed on channel 1
Killed by signal 1.
[2] 21:38:00 [SUCCESS] host1
hi
Stderr: 
This is a private site.  Unauthorized connections are prohibited.  
All activity may be logged.  Disconnect immediately if you object to 
this policy or are not an authorized user.

ControlSocket /home/user1/.ssh/master-user1@ssh-tunnel.mydomain.com:22 already exists, disabling multiplexing
X11 forwarding request failed on channel 0
Killed by signal 1.

当上述操作正常时,您将注意到我正在运行的命令echo "hi"的输出。

您的问题

您在SSH密钥对上使用密码时遇到的问题是一个错误造成的。这是一个名为:问题80:没有通过密码?的bug。对该问题的第4条评论显示了一个补丁:

节选

#4 robine...@gmail.com我在prompt.strip().lower():中将行改为if (prompt.strip().lower().endswith(密码:)或输入密码短语.lower())。

参考资料

  • 在多个主机上执行命令的并行SSH
票数 5
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/128974

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档