简体   繁体   English

使用 ssh 密钥进行多用户登录的 AWS ec2 实例不起作用

[英]AWS ec2 instance with Multi user login with ssh key not work

I have a server(ubuntu16.04) in aws ec2.我在 aws ec2 中有一个服务器(ubuntu16.04)。 And I have a private key to access the server.我有一个私钥来访问服务器。 The origin user I used called ubuntu which is generated by aws.我使用的原始用户名为ubuntu ,它是由 aws 生成的。 Now my client B wants to login server to synchronize(it's a window10 pc).现在我的客户 B 想登录服务器进行同步(它是一个 windows10 电脑)。 I don't want to use my aws private key in different places.我不想在不同的地方使用我的 aws 私钥。 So I create a new user which has a limited right called syncusr .因此,我创建了一个名为syncusr的具有有限权限的新用户。

$ cat /etc/passwd
syncusr:x:1002:1002::/home/syncusr:

I generated ssh-key (ssh-keygen) then append public key to authorized_keys in ~/.ssh我生成了 ssh-key (ssh-keygen) 然后 append 公钥到 ~/.ssh 中的 authorized_keys

$ ls -ld ~/.ssh; ls -l ~/.ssh
drwx------ 2 syncusr syncusr 4096 May 15 12:14 /home/syncusr/.ssh
total 8
-rw-r--r-- 1 syncusr syncusr  404 May 15 12:13 authorized_keys
-rwxrwxrwx 1 syncusr syncusr 1679 May 15 12:13 id_rsa

Now I download id_rsa and run PuTTYgen got a private key, then I login from client B with username syncusr and private key but failed.现在我下载 id_rsa 并运行 PuTTYgen 得到一个私钥,然后我从客户端 B 使用用户名 syncusr 和私钥登录但失败了。

. 2020-05-15 12:17:00.335 Initialised AES-256 SDCTR (AES-NI accelerated) outbound encryption
. 2020-05-15 12:17:00.335 Initialised HMAC-SHA-256 outbound MAC algorithm
. 2020-05-15 12:17:00.335 Initialised AES-256 SDCTR (AES-NI accelerated) inbound encryption
. 2020-05-15 12:17:00.335 Initialised HMAC-SHA-256 inbound MAC algorithm
. 2020-05-15 12:17:00.507 Reading key file "D:\SSHKEY\private_key.ppk"
! 2020-05-15 12:17:00.507 Using username "syncusr".
. 2020-05-15 12:17:00.709 Server offered these authentication methods: publickey
. 2020-05-15 12:17:00.709 Offered public key
! 2020-05-15 12:17:00.901 Server refused our key
. 2020-05-15 12:17:00.918 Server refused our key
. 2020-05-15 12:17:00.918 Server offered these authentication methods: publickey
. 2020-05-15 12:17:00.918 No supported authentication methods available (server sent: publickey)
. 2020-05-15 12:17:00.918 Attempt to close connection due to fatal exception:
* 2020-05-15 12:17:00.918 No supported authentication methods available (server sent: publickey)

which part did I miss?我错过了哪一部分?

在此处输入图像描述

Set your authorized_keys file to 600 permission.将您的 authorized_keys 文件设置为 600 权限。

Also as an FYI id_rsa should be 400 permission (but not relevant to this question).另外作为一个 FYI id_rsa 应该是 400 权限(但与这个问题无关)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM