我有一台服务器,我使用 SSH 连接该服务器,并且使用我的密钥文件,例如id_rsa.pub
。
我按照教程禁用根身份验证和密码使用以提高安全性(通过/etc/ssh/sshd/sshd_config
在服务器上配置文件)。
到目前为止,我可以轻松地使用 rsync 将文件从我的计算机同步到服务器。
几天之前, 我使用了 cron 作业工作,为此我必须在服务器端重置我的根密码。
从那时起,我就无法在 SSH 中使用 rsync,我收到以下消息:
[email protected]: Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far)[sender]
rsync error: unexplained error (code 255) at io.c(235)[sender=3.1.3]
有一些类似的主题,但我认为我的情况有点不同,因为我认为问题是由于在服务器上重置我的密码造成的。
我不知道如何修复这个问题(我懂一点终端命令,但我不是计算机专家)。你能帮帮我吗?
非常感谢!
编辑 :
/etc/ssh/sshd_config
仅供您参考,请找到调整不使用密码的教程:
#Uncomment or add the following line.
#This allows the server to give its DSA footprint in case of an ssh connection.
HostKey /etc/ssh/ssh/ssh_host_dsa_key
#Then set the next parameter to 20s (for example).
#This is the time during which a connection without being logged in will be opened.
#If we had kept the good old password technique, leave 2 or 3 minutes to type it, it's not too much.
#But since we're using the key now, we'll be logged in immediately. #So we can really reduce the thing and put it down to 20 seconds for example.
LoginGraceTime 20s
#this is the maximum number of attempts before being thrown by the server....
#Since with the key, no possible error, you can put it to 1 possible test.
MaxAuthTries 1
#Then, we will tell the SSH server where the keys are and tell it that we will use them as an authentication method
PubkeyAuthentication yes
AuthorizedKeysFile.ssh/authorized_keys
#And of course, we'll disable all other authentication methods
RSAAuthentication no.
UsePAM no
KerberosAuthentication no
GSSAPIA Authentication no.
PasswordAuthentication no
#Then, we will tell that we only allow users of the sshusers group (for more security)
AllowGroups sshusers
#The MaxStartups setting indicates the number of un-authenticated ssh connections you can launch at the same time.
#2 is more than enough, knowing that with the keys, it's instantaneous.
MaxStartups 2