SSH 要求我输入密码,但没有任何密码

SSH 要求我输入密码,但没有任何密码

我已经使用以下命令在 Ubuntu 14.04 系统中生成了密钥以与 ssh 一起使用。

 ssh-keygen -t rsa -b 2048
 openssl rsa -in id_rsa -outform pem > pk_rsa.pem
 openssl rsa -in pk_rsa.pem -pubout -out my_key.pem

我已将 my_key.pem 复制到本地 OSX。尝试使用以下命令 ssh 进入 Ubuntu

 ssh -v -i ./my_key.pem [email protected] 
 OpenSSH_7.4p1, LibreSSL 2.5.0
 debug1: Reading configuration data /etc/ssh/ssh_config
 debug1: Connecting to 192.168.113.137 [192.168.113.137] port 22.
 debug1: Connection established.
 debug1: key_load_public: No such file or directory 
 debug1: identity file ./ubu14.pem type -1
 debug1: key_load_public: No such file or directory
 debug1: identity file ./ubu14.pem-cert type -1
 debug1: Enabling compatibility mode for protocol 2.0
 debug1: Local version string SSH-2.0-OpenSSH_7.4
 debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8
 debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.8 pat OpenSSH_6.6.1* compat 0x04000000
 debug1: Authenticating to 192.168.113.137:22 as 'ubuntu'
 debug1: SSH2_MSG_KEXINIT sent
 debug1: SSH2_MSG_KEXINIT received
 debug1: kex: algorithm: [email protected]
 debug1: kex: host key algorithm: ecdsa-sha2-nistp256
 debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
 debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
 debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
 debug1: Server host key: ecdsa-sha2-nistp256 SHA256:KDokJiZiQ9ZflT5Jm5B8krQ8XgsEEgUjQjg+h6C4Gqo
 debug1: Host '192.168.113.137' is known and matches the ECDSA host key.
 debug1: Found key in /Users/macdev/.ssh/known_hosts:11
 debug1: rekey after 134217728 blocks
 debug1: SSH2_MSG_NEWKEYS sent
 debug1: expecting SSH2_MSG_NEWKEYS
 debug1: SSH2_MSG_NEWKEYS received
 debug1: rekey after 134217728 blocks
 debug1: SSH2_MSG_SERVICE_ACCEPT received
 debug1: Authentications that can continue: publickey,password
 debug1: Next authentication method: publickey
 debug1: Trying private key: ./my_key.pem
 Enter passphrase for key './my_key.pem': 
 debug1: Next authentication method: password
 [email protected]'s password: 

有办法解决这个问题吗?

答案1

您正在混淆两种不同的技术,openssh并且openssl。看来您只需要前者。

由于您已经创建了 ssh 密钥对,因此只需将公钥复制到您想要 ssh 的服务器即可。正确的方法是:

$ ssh-copy-id username@<server-ip>

代替用户名和 <服务器IP> 使用您的服务器的用户和 IP 地址。

相关内容