【问题标题】:SSH - Permission denied (publickey) for created user [closed]SSH - 创建用户的权限被拒绝(公钥)[关闭]
【发布时间】:2017-08-08 04:09:10
【问题描述】:

我可以使用 SSH 连接到 digitalocean 服务器:

ssh root@1.1.1.1(使用正确的 IP 地址)

但是,添加用户后:

adduser git
...
is this information correct?
Y
...

我无法与这个新用户进行 SSH 连接

ssh git@1.1.1.1
Permission denied (publickey).

为什么我的公钥对于root 是正确的,但对于git 不正确?

更新

如果重要的话,我正在使用 digitalocean。

【问题讨论】:

    标签: linux ubuntu unix ssh ubuntu-16.04


    【解决方案1】:

    我知道这个问题,你面临什么,你需要检查你的密钥的权限。 更改用户权限。我确实有一个相同的问题,我可以通过 https 而不是通过 ssh 克隆 git。

    chmod 实用程序将解决您的问题:

    这个命令会解决你的问题。

    chmod 777 <id_rsa_key(file)>
    

    其他一些常用的例子是:

    777 anyone can do anything (read, write, or execute)
    755 you can do anything; others can only read and execute
    711 you can do anything; others can only execute
    644 you can read and write; others can only read
    

    【讨论】:

    • rsa 密钥文件在哪里?
    • 检查这个路径 .~/.ssh,你会在你的机器上保存你的公钥。 .sometime 你可能有扩展名 *.pub, .ssh/id_rsa.pub
    • 看起来 digitalocean 在~/.ssh/root/.ssh 中放置了一个authorized_keys 文件。在将两者都设置为777(暂时)之后,我仍然无法使用新创建的用户进行 ssh。我还使用service ssh restart 重新启动了 SSH。
    • 我也尝试将authorized_keys 复制到/home/git/.ssh 并将其权限更改为777,但仍然没有成功。
    • 没关系,它确实有效。在/home/git/.ssh中更改authorized_keys的权限后,我测试的IP不正确。
    猜你喜欢
    • 2015-07-15
    • 2017-11-09
    • 2018-07-20
    • 2019-11-24
    • 2014-11-08
    • 2019-03-11
    • 1970-01-01
    • 2019-03-08
    • 2019-08-20
    相关资源
    最近更新 更多