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

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

我在 aws ec2 中有一个服务器(ubuntu16.04)。我有一个访问该服务器的私钥。我使用的原始用户名为ubuntu由 aws 生成的。现在我的客户端 B 想要登录服务器进行同步(它是一台 windows10 pc)。我不想在不同的地方使用我的 aws 私钥。所以我创建了一个具有有限权限的新用户,名为syncusr

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

我生成了 ssh-key(ssh-keygen),然后将公钥附加到 ~/.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

现在我下载 id_rsa 并运行 PuTTYgen 获得私钥,然后我使用用户名 syncusr 和私钥从客户端 B 登录但失败了。

. 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)

我错过了哪一部分?

在此处输入图片描述

解决方案:

drwx------ 2  /home/sync1/.ssh
total 8
-rw-r--r-- 1  authorized_keys
-rw------- 1  id_rsa

相关内容