[英]Unable to ssh to remote server
I'm trying to log in to a particular user on my lightsail account via ssh but I get a permission denied (public key) error 我正在尝试通过ssh登录到我的lightail帐户中的特定用户,但我收到一个权限被拒绝(公钥)错误
Here are the steps I followed(I am on git bash on windows 8) 这是我遵循的步骤(我在Windows 8上是git bash)
ssh into my lightsail account via the .pem key provided via aws 通过aws提供的.pem密钥ssh进入我的lightail帐户
ssh -i <key.pem> ubuntu@<public_ip_address>
(I am now logged in to my lightsail server) (我现在已经登录到我的lightail服务器)
sudo adduser user1
sudo touch /etc/sudoers.d/user1
sudo nano /etc/sudoers.d/user1
** user1 ALL=(ALL:ALL) ALL** ** user1 ALL =(全部:全部)全部**
su - user1
sudo mkdir .ssh
sudo touch .ssh/authorized_keys
I open Another shell prompt and do the following 我打开另一个shell提示,然后执行以下操作
- ssh-keygen
ssh-keygen
- cat <file_location_of_key>.pub
-
cat <file_location_of_key>.pub
-copy the contents -复制内容
I exit from the lightsail account and try to ssh to the grader user 我退出了lightail帐户,并尝试通过SSH转到平地机用户
ssh -i <file_location_of_key> user1@<public_ip_address>
I get the error Permission denied (publickey). 我收到错误权限被拒绝(公钥)。
Note: I havn't changed any port setting yet. 注意:我尚未更改任何端口设置。 I'm still trying to connect it to my default port 22
我仍在尝试将其连接到默认端口22
@RickBaker @helloV Thanks for your help. @RickBaker @helloV感谢您的帮助。 Realised the file was still owned by root.
意识到该文件仍由root拥有。 Had to change to ownership of the file to user1.
不得不将文件的所有权更改为user1。 ssh works fine now
SSH现在可以正常工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.