%20%D1%81%20SSH.png)
У меня есть сервер, к которому я подключаюсь по SSH с помощью моих файлов ключей, таких как id_rsa.pub
. Я использую Debian на стороне клиента и сервера.
Я следовал инструкции, чтобы отключить аутентификацию root и использование пароля для большей безопасности (путем настройки /etc/ssh/sshd/sshd_config
файла на сервере).
До сих пор я мог легко использовать его rsync
для синхронизации файлов со своего компьютера на сервер.
Несколько дней назад, Я использовал задание cronработа, и для этого мне пришлось сбросить пароль root на стороне сервера.
С тех пор я не могу использовать его rsync
в SSH
; я получаю следующее сообщение:
[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]
Есть несколько похожих тем, но я думаю, что мой случай немного отличается, потому что я думаю, что проблема связана со сбросом моего пароля на сервере. Я также задал вопрос на сайте Ask Ubuntu, но я думаю, что, возможно, люди здесь более опытны в вопросах разрешений.
Я понятия не имею, как решить эту проблему (я немного разбираюсь в терминальных командах, но я не эксперт в компьютерах). Не могли бы вы мне помочь, пожалуйста?
Только для вашего сведения, пожалуйста, ознакомьтесь с руководством по настройке пароля, /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
решение1
Я только что нашел решение... Моя команда была:
sudo rsync -avz -e "ssh -p <port>" <source> <destination>
Но мне пришлось сделать это просто (без sudo
):
rsync -avz -e "ssh -p <port>" <source> <destination>
Я не уверен в причине, но думаю, что root
пользователю моего настольного компьютера не был разрешен доступ к моему серверу по SSH, поскольку ключ был только для classic
пользователя моего настольного компьютера (то есть без sudo).
Может ли кто-нибудь подтвердить? Спасибо.