我有一个服务器(ubuntu16.04)在aws ec2。我有一个访问服务器的私钥。ubuntu
现在我的客户B想登录服务器进行同步(这是一个window10的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)
我错过了哪一部分?
将你的authorized_keys文件设置为600权限。
另外,仅供参考,id_rsa应该是400权限(但与这个问题无关)。