当尝试 ssh -v 'somehost'
Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/kaldown/.ssh/id_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/kaldown/.ssh/id_dsa
debug1: Trying private key: /home/kaldown/.ssh/id_ecdsa
debug1: Trying private key: /home/kaldown/.ssh/id_ed25519
debug1: No more authentication methods to try.
Permission denied (publickey).
为什么他说这是 1 型而不是 2 型
debug1: identity file /home/kaldown/.ssh/id_rsa type 1
debug1: identity file /home/kaldown/.ssh/id_rsa-cert type -1
debug1: identity file /home/kaldown/.ssh/id_dsa type -1
debug1: identity file /home/kaldown/.ssh/id_dsa-cert type -1
debug1: identity file /home/kaldown/.ssh/id_ecdsa type -1
debug1: identity file /home/kaldown/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/kaldown/.ssh/id_ed25519 type -1
debug1: identity file /home/kaldown/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1_hpn13v11 FreeBSD-20140420
在 sshd_config 中:
PermitRootLogin no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PermitEmptyPasswords no
PasswordAuthentication no
ChallengeResponseAuthentication no
GSSAPIAuthentication no
UsePAM yes
UsePrivilegeSeparation sandbox
PS 我正在使用 FreeBSD 10.1,它在 ssh-copy-id 方面存在问题,提示奇怪的
Unmatched '
所以我只需将我的公钥复制到特定用户的 .ssh/authorized_keys 中即可
1)为什么使用.ssh/id_rsa而不是.ssh/id_rsa.pub作为公钥?
2)为什么当我使用 ssh -t rsa (rsa2) 密钥创建此文件时,它会告诉我类型 1
3)为什么我无法使用密钥连接,而只能使用该配置输入密码。
服务器端:CentOS 7,3.10
谢谢。
答案1
您的id_rsa
文件包含有关您的私钥和公钥的信息。它仅提供密钥的公共部分。
我相信类型 1 或类型 2 指定它是 RSA 还是 DSA 密钥。
答案2
sshd_config 用于服务器,因此您要在此文件中查找公钥,以确保它与客户端发送的私钥相匹配。
服务器上的公钥位于 ~/.ssh/authorized_keys
然后客户端将其私钥发送到 ~/.ssh/id_rsa 中,服务器会匹配它们并允许您进入
客户端设置在这里
[[email protected] /etc/ssh]# grep IdentityFile /etc/ssh/ssh_config
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
这些评论也意味着它们是客户端的默认设置。
如果你想发送不同的密钥,你可以这样做
ssh -i /path/to/key/file [email protected]