将SSH密钥添加到Digital Ocean后,权限被拒绝错误

时间:2018-07-12 07:16:03

标签: ssh digital-ocean

我有一台运行正常的Windows计算机,但在Mac OS X Sierra 10.13.5上,出现此错误Permission denied (publickey)

需要重新开始的步骤:

  1. 我删除了〜/ .ssh / id_rsa和〜/ .ssh / id_rsa.pub
  2. 我备份了〜/ .ssh / known_hosts(运行了mvknown_host known_hostBackup)(然后运行触摸known_host)。因此,我认为每件事都应该干净并准备好生成新的ssh密钥...
  3. Ran ssh-keygen
  4. 跑猫id_rsa.pub并复制了新的ssh密钥

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDOZoANykFA4ta2ft4wSS9Hqsvi+b8r3XDaUlBSPRyPzwXXXXX≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈≈XXXXXaWfO3X9SEFtE7Qe8NxXjmkgC4BYZSg4QFRV2Is5PiUn5MXs4StmNzZGcj8kFQd4PG0go1FqAsixT myname@apples-mbp

  1. 转到数字海洋/设置/安全性/ SSH密钥,创建一个新密钥并粘贴整个SSH密钥。

我仍然收到错误 root@128.261.64.32: Permission denied (publickey)

我是否缺少本地设置?

2 个答案:

答案 0 :(得分:0)

确保可以在sshd中禁用用于root用户或root用户的密钥。有关详细信息,请参阅this。可能会对您有帮助。

答案 1 :(得分:0)

谢谢你,

我错过了将authorized_keys添加到服务器的步骤。这样就解决了:

https://www.digitalocean.com/community/questions/how-do-i-add-an-ssh-key-to-an-existing-droplet

cat〜/ .ssh / id_rsa.pub | ssh user@123.45.56.78“ mkdir -p〜/ .ssh && cat >>〜/ .ssh / authorized_keys”