【问题标题】:Need help getting my ssh keys to work on a digital ocean droplet需要帮助让我的 ssh 密钥在数字海洋水滴上工作
【发布时间】:2017-07-17 11:23:20
【问题描述】:

在创建新的 Droplet 时,我检查了 SSH 选项并粘贴了我的公钥(在我的 AWS 上可以正常工作)Droplet 但无法登录到新的 Droplet。两个实例都使用 ubuntu。通过阅读文档,我了解到如果在创建实例时提供 SSH 密钥,则不会发送带有 root 密码的电子邮件。不知道为什么提示我输入密码。协助将不胜感激。

这是我尝试登录的会话:

TLOMBARD-M-T8T8:.ssh tlombard$ ssh root@107.170.209.13
The authenticity of host '107.170.209.13 (107.170.209.13)' can't be established.
ECDSA key fingerprint is SHA256:CsusP0faav9SqEfSXpXpMjeEEp2GXrT77OT35x3TJco.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '107.170.209.13' (ECDSA) to the list of known hosts.
root@107.170.209.13's password: 
Permission denied, please try again.
root@107.170.209.13's password: 
Permission denied, please try again.

【问题讨论】:

    标签: ssh digital-ocean


    【解决方案1】:

    首先确保您输入的密码正确,然后更新您的 sshd_config 文件以启用密码验证。

    在你的 ubuntu cli 上执行:sudo nano /etc/ssh/sshd_config

    然后将密码验证行从PasswordAuthontication: no更新为PasswordAuthentication:yes

    重启你的ssh服务执行sudo service ssh restart

    【讨论】:

      【解决方案2】:

      您需要检查您的 Droplet 上的 SSH 配置。

      • 通过控制台登录(在 Digital Ocean 网站上)
      • su(成为root)
      • 编辑文件/etc/ssh/sshd_config
      • 搜索设置PermitRootLogin并将其设置为:

        PermitRootLogin: without-password

      • 同时检查PasswordAuthentication 并确保它设置为:

        PasswordAuthentication: no

      PermitRootLogin 确保 SSH 期待 root 的密钥登录。我认为这就是你所需要的,但是设置 PasswordAuthentication 也没有什么坏处,它只为所有用户设置键控。

      一定要运行

      systemctl reload sshd 
      

      这将使用 ubuntu 16.04 的新设置重新启动 SSH。 (我认为 14.04 是service ssh restart)。

      【讨论】:

      • 我已经按照您的建议进行了更改。但 ssh 仍然提示输入密码 - 是否需要重新启动?
      • @TimothyLombard,对不起,我忘了补充说您可以重新加载 SSH 服务以加载新设置,请参阅更新的答案,在末尾添加命令。
      【解决方案3】:

      您可以通过 droplet 控制面板重置 root 密码。然后您可以通过 SSH 连接到 droplet 并添加您的 SSH 密钥。

      https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2

      【讨论】:

      • 我尝试使用:ssh-copy-id -i user.pub root@107.170.209.13 它似乎有效(现在.ssh/authorized_keys 文件中有一个条目)但我登录时仍然提示输入密码。
      【解决方案4】:

      运行:sudo vim /etc/ssh/sshd_config

      并将以下两个设置更改为 yes

      1. PermitRootLogin yes

      2. PasswordAuthentication yes

      现在设置root密码:sudo passwd root

      重启SSH:sudo service sshd restart

      【讨论】:

        猜你喜欢
        • 2016-10-03
        • 2019-10-04
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-05-10
        相关资源
        最近更新 更多