我正在跟进这教程,这就是我正在尝试的
ssh-copy-id -i ~/.ssh/id_rsa.pub remote_host
它说Permission denied (publickey,password).
我也尝试过ssh -v remote_host
并验证过
debug1: Reading configuration data /Users/praful/.ssh/config
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to remote_host port 22.
debug1: Connection established.
debug1: identity file /Users/praful/.ssh/id_rsa type 1
debug1: identity file /Users/praful/.ssh/id_rsa-cert type -1
debug1: identity file /Users/praful/.ssh/id_dsa type -1
debug1: identity file /Users/praful/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH*
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<2048<8192) 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: Server host key: RSA 55:60:e4:78:c8:98:09:d2:0f:d3:69:73:b9:e0:99:60
debug1: Host is known and matches the RSA host key.
debug1: Found key in /Users/praful/.ssh/known_hosts:63
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/praful/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /Users/praful/.ssh/id_dsa
debug1: Next authentication method: password
root@remote_host's password:
答案1
您应该提供私钥ssh-copy-id
或者根本不提供密钥,如命令概要中所述(来自手册页):
ssh-copy-id [...] [-i [identity_file]] [-p port] [-o ssh_option] [user@]hostname
或者根本没有密钥(在这种情况下,它将复制标准位置中的所有密钥)。使用以下命令应该可以完成这项工作:
ssh-copy-id -i ~/.ssh/id_rsa remote_host
如果没有帮助,请运行
ssh-copy-id -i ~/.ssh/id_rsa -o LogLevel=DEBUG3 remote_host
并使用输出更新问题以进行进一步调查。