我正在尝试使用 openssh 和私钥/公钥从 Windows 2003 服务器连接到 unix 服务器,但一直要求提供私钥密码和 Windows 密码。
我已经在 linux 上的授权密钥上添加了公钥(如果我使用 putty 连接并且私钥工作正常)。但我需要使用 bash 脚本进行连接,而不需要请求密码和密码。
这是命令:
ssh -v -i privatefile -p 2022 user@server
这是日志:
OpenSSH_3.7.1p1, SSH protocols 1.5/2.0, OpenSSL 0.9.7b 10 Apr 2003
debug1: Connecting to SERVER port 2022.
debug1: Connection established.
debug1: identity file privatefile type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_3.7.1p1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-cbc hmac-sha1 none
debug1: kex: client->server aes128-cbc hmac-sha1 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST 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
debug1: Host 'SERVER' is known and matches the RSA host key.
debug1: Found key in /cygdrive/c/Users/PAMA1/.ssh/known_hosts:1
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
D:\Entrada\z_Bkp>NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
Anyone gaining unauthorized access will be subject to PROSECUTION.
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mi
c,password,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: bilaetlopenssh
Enter passphrase for key 'bilaetlopenssh':
debug1: Next authentication method: keyboard-interactive
Enter your Windows password :
答案1
如果使用putty
,你可以使用puttygen
动态存储密钥私钥,输入密码密钥一次(即直到重新启动)。
建议的操作是保存与远程主机、远程用户和使用的密钥的会话,并使用该会话运行命令会议。
\path\name\to\putty.exe -load "mysession"
所以要使用腻子复制pscp
:
\path\name\to\pscp.exe -load "mysession" local-file.txt remote:/path/file.txt
\path\name\to\pscp.exe -load "mysession" remote:/path/file.txt local-file.txt
在unix世界中puttygen
被称为ssh-add
,我没有WSL来测试它。