在Cygwin中使用sshpass,ssh仍然提示输入密码

在Cygwin中使用sshpass,ssh仍然提示输入密码

根据这个RedHat SSH 密码自动化指南我正在关注示例 4:GPG一,按照该指南中的步骤,我pass_file使用自己的密码创建我的密码。然后,我得到了这个:

gpg -d -q myappserver23.sshpasswd.gpg > pass_file && sshpass -fpass_file ssh [email protected]

-f请注意选项和pass_file根据之间缺少空格sshpass 手册页 当我运行上面的命令时,系统会要求我输入密码,我正确地输入它,然后系统会要求我输入服务器的密码,就好像sshpass根本没有使用过一样。简而言之,这有效我仍然收到密码提示...

我当然知道这些-q选项,并且我也添加了-vvv这两个选项sshpassSSH这似乎与并且不sshpass我相信。我将在这里分享 ssh 横幅消息后收到的调试消息

(...)
debug3: input_userauth_banner
----------------------------------------------------------------------------------------
Here goes ssh banner message
----------------------------------------------------------------------------------------

debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug3: start over, passed a different list publickey,gssapi-keyex,gssapi-with-mic,password
debug3: preferred publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering public key: C:\\Users\\myuser/.ssh/id_rsa RSA SHA256:7PAz6lsENYkfYGwFZWNf0OJ88Z9mFDMSBc+P9t+4H1k
debug3: send packet: type 50
debug2: we sent a publickey packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Trying private key: C:\\Users\\myuser/.ssh/id_dsa
debug3: no such identity: C:\\Users\\myuser/.ssh/id_dsa: No such file or directory
debug1: Trying private key: C:\\Users\\myuser/.ssh/id_ecdsa
debug3: no such identity: C:\\Users\\myuser/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: C:\\Users\\myuser/.ssh/id_ed25519
debug3: no such identity: C:\\Users\\myuser/.ssh/id_ed25519: No such file or directory
debug1: Trying private key: C:\\Users\\myuser/.ssh/id_xmss
debug3: no such identity: C:\\Users\\myuser/.ssh/id_xmss: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup password
debug3: remaining preferred: ,password
debug3: authmethod_is_enabled password
debug1: Next authentication method: password
debug3: failed to open file:C:/dev/tty error:3
debug1: read_passphrase: can't open /dev/tty: No such file or directory
[email protected]'s password:

此输出的最后一行是密码提示。显然,如果我在这里输入密码,我将能够登录远程服务器,但是使用它有什么意义呢sshpass?我希望能够无需输入任何密码即可登录。

请不要建议使用私钥,我了解这个主题,但它不适用于我的现实世界场景。任何帮助将不胜感激。

答案1

@KamilMaciorowski 评论让我找到了正确的方向。根据 ServerFault 上的这个有用的答案,视窗正在采取自己的开放SSH执行。要解决这个问题,openssh必须安装西格文为了使用这个来代替。

这解决了错误,现在我可以这样做:

$ gpg -d -q myappserver23.sshpasswd.gpg > pass_file && sshpass -fpass_file ssh [email protected] > test.txt

$ cat test.txt
/home/myuser
uid=1001(myuser) gid=1001(mygroup) groups=1001(mygroup)

PD。这并不是不安全,因为我们gpg在这里使用。但如果有疑问,尝试这个

答案2

为什么要解密为留在文件系统中的纯文本文件?最好管道直接输出:

gpg -d -q myappserver23.sshpasswd.gpg | sshpass -P pass ssh -i ~/.ssh/key.pem -ttR xxx.xxx.xxx.xxx

-P pass选项搜索例如“密码...”或“密码短语”提示以填充。

相关内容