ssh 如何停止权限被拒绝(公钥)

ssh 如何停止权限被拒绝(公钥)

在每个过程中 SSH 都会返回权限被拒绝(公钥)。

ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 4 key(s) remain to be installed -- if you are prompted now it is to install the new keys
Permission denied (publickey).


ssh [email protected]
Permission denied (publickey).

当我尝试使用 -vvv 然后返回

debug1: Trying private key: /home/leo/.ssh/id_dsa
debug3: no such identity: /home/leo/.ssh/id_dsa: No such file or directory
debug1: Trying private key: /home/leo/.ssh/id_ecdsa
debug3: no such identity: /home/leo/.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /home/leo/.ssh/id_ed25519
debug3: no such identity: /home/leo/.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Permission denied (publickey).

如何停止 SSH 权限被拒绝(公钥)并连接到主机服务器?

答案1

看起来在您的服务器上您只能使用密钥登录,而不能使用密码登录。

如果你在服务器站点上的公钥被添加到, /root/.ssh/authorized_keys那么你应该能够登录ssh [email protected] -i /path/to/key

如果您没有密钥,可以按照以下步骤操作:

  1. 在您的客户端运行中ssh-keygen,默认情况下密钥是在 ~/.ssh/id_rsa 处创建的
  2. 还有一个id_rsa.pub创建。复制该行id_rsa.pub并将其添加到服务器上/root/.ssh/authorized_keys
  3. 使用以下方式登录到您的服务器ssh [email protected] -i ~/.ssh/id_rsa

相关内容