我正在尝试设置对我自己的本地机器的 ssh 访问。
我已经使用 ssh-keygen 创建了 id_rsa 密钥。我将 id_rsa.pub 添加到 .ssh/ 中的 authroized_keys 我确保authorized_keys 的权限是 640 我在 sshd_config 中启用了公钥身份验证并重新启动了 ssh
RSAAuthentication 是
PubkeyAuthentication 是
AuthorizedKeysFile %u/.ssh/authorized_keys
但是我无法登录到 ssh。
我收到的错误如下
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'localhost' is known and matches the ECDSA host key.
debug1: Found key in /home/rahul/.ssh/known_hosts:6
debug1: ssh_ecdsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug2: service_accept: ssh-userauth
debug2: key: /home/rahul/.ssh/id_rsa (0x7fa12de58e70),
debug2: key: /home/rahul/.ssh/gitHubKey ((nil)), explicit
debug2: key: /home/rahul/.ssh/id_rsa_buhlServer (0x7fa12de59060), explicit
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/rahul/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug1: Trying private key: /home/rahul/.ssh/gitHubKey
no such identity: /home/rahul/.ssh/gitHubKey: No such file or directory
debug1: Offering RSA public key: /home/rahul/.ssh/id_rsa_buhlServer
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).
Run Code Online (Sandbox Code Playgroud)
您是否看到过 auth.log(或 system.log、secure.log,等等,opensshd 写日志的地方)可能的问题是 .ssh/authorized_keys 必须有 600 而不是 640。
示例:https : //help.ubuntu.com/community/SSH/OpenSSH/Keys
chmod go-w ~/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys
Run Code Online (Sandbox Code Playgroud)
希望能帮助到你。
我们将卸载 openssh-server 并清除配置文件:
(root)# apt-get remove --purge openssh-server
Run Code Online (Sandbox Code Playgroud)
现在我们将使用默认设置再次安装:
(root)# apt-get install openssh-server
Run Code Online (Sandbox Code Playgroud)
现在我们将生成我们的私钥/公钥:
(rahul)$ ssh-keygen
Run Code Online (Sandbox Code Playgroud)
现在我们将复制本地用户中的密钥,您需要输入密码。
(rahul)$ ssh-copy-id rahul@localhost
Run Code Online (Sandbox Code Playgroud)
现在尝试连接:
(rahul)$ ssh rahul@localhost
Run Code Online (Sandbox Code Playgroud)
现在它可以工作了。
| 归档时间: |
|
| 查看次数: |
8283 次 |
| 最近记录: |