新用户的权限被拒绝

新用户的权限被拒绝

创建新用户并授予其 sudo 权限后,其权限被拒绝。

我是 root 用户,以 ubuntu@nameserver 身份登录,当我尝试使用我自己创建的用户登录时,出现权限被拒绝(公钥)的情况

我遵循的步骤:

root@nameserver#  adduser newuser
root@nameserver#  usermod -aG sudo newuser

后:

ubuntu@thapp:~$ ssh -vvv newuser@nameserver

我得到:

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

我看到许多帖子提供了各种命令,但他们并不清楚如何使用它们。

IE。:

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

如果服务器站点上的公钥已添加到 /root/.ssh/authorized_keys,那么您应该能够使用 ssh 登录[电子邮件保护]-i /路径/到/键

參考文獻:最新的超级用户帖子

我如何知道/path-to-key?

即使以 root 身份登录:

ubuntu@nameserver:~$ /root/.ssh/authorized_keys
-bash: /root/.ssh/authorized_keys: Permission denied
ubuntu@nameserver:~$ sudo su
root@nameserver:/home/ubuntu# /root/.ssh/authorized_keys
bash: /root/.ssh/authorized_keys: Permission denied
root@nameserver:/home/ubuntu#

请用一个我可以遵循的示例来指导命令,以及我应该如何登录。我已将实例的私钥和公钥下载到本地电脑,我使用 Putty 登录并单独使用密钥来访问它。

最好的。

答案1

请谷歌:“如何配置基于 SSH 密钥的身份验证”顺便说一句,您的权限被拒绝,因为您尝试运行该文件。尝试:cat /root/.ssh/authorized_keys 如果您想使用与 root 相同的密钥登录,但使用用户 ubuntu:

mkdir ~ubuntu/.ssh
cp /root/.ssh/authorized_keys ~ubuntu/.ssh
chown -R ubuntu: ~ubuntu/.ssh
chmod 700 ~ubuntu/.ssh
chmod 600 ~ubuntu/.ssh/authorized_keys

相关内容