我想通过公钥身份验证使用 paramiko ssh2 到远程主机,我像以下步骤一样设置密钥:
在本地:
Local> ssh-keygen
Generating 1024-bit dsa key pair
9 o.oOo..oOo.o
Key generated.
Passphrase :
Again :
Private key saved to /home/local/.ssh2/id_dsa_1024_a
Public key saved to /home/local/.ssh2/id_dsa_1024_a.pub
Local> cd ~/.ssh2
Local> echo "IdKey id_dsa_1024_a" > identification
Local> scp id_dsa_1024.pub remote@remote-host:~/.ssh2/local.pub
在远程:
Remote> ssh-keygen
...omit...
Remote> cd ~/.ssh2
Remote> echo "Key local.pub" > authorization
完成上述操作后,我就可以使用ssh remote@remote-host
登录了。
但是,我未能使用 python 的 paramiko 模块登录远程主机:
conn = paramiko.SSHClient()
conn.set_missing_host_key_policy(paramiko.AutoAddPolicy())
conn.connect(remote-host, 22, username=remote,password='')
总是错误:身份验证失败。
我很混乱。:(