[英]I am able to ssh to remote server only if i am sudo
I researched and found that to change mod of.ssh to 700 so我研究并发现将.ssh的mod更改为700所以
[ec2-user@ip-114 .ssh]$ sudo cp /root/.ssh/id_rsa /home/ec2-user/.ssh/id_rsa
[ec2-user@ip-114 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
[ec2-user@ip-114 .ssh]$ pwd
/home/ec2-user/.ssh
[ec2-user@ip-114 ~]$ cd ..
[ec2-user@ip-114 ~]$ chmod 700 .ssh/
[ec2-user@ip-114 ~]$ cd .ssh/
[ec2-user@ip-114 .ssh]$ ssh -i "id_rsa.pub" ubuntu@x.x.x.x
Load key "id_rsa.pub": Permission denied
Permission denied (publickey).
[ec2-user@ip-114 .ssh]$ ls
authorized_keys id_rsa id_rsa.pub known_hosts
Even after change mod it saying permision denied.即使在更改 mod 之后它说权限被拒绝。
If i do如果我做
sudo su
[ec2-user@ip-114 .ssh]$ sudo su
[root@ip-172-114 .ssh]# ssh ubuntu@x.x.x.x
Enter passphrase for key '/root/.ssh/id_rsa':
Which is target behaviour for non root user.这是非 root 用户的目标行为。
Whats going wrong?怎么了?
You are trying to connect via the public key, you should be connecting via id_rsa
.您正在尝试通过公钥进行连接,您应该通过
id_rsa
进行连接。
Additionally please make sure it has permissions 400 with your user as the owner.此外,请确保您的用户作为所有者拥有 400 权限。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.