В доступе отказано (publickey). AWS: ошибка подключения Ec2 в Ubuntu 18

Некоторое время назад я смог подключиться к своему серверу, используя SSH, и вдруг он перестал работать.

Я пытаюсь выполнить команду: ssh -i "mykey.pem" ubuntu@server-ip, и Ec2 возвращает исключение

Permission denied (publickey). Когда я пытался установить соединение с использованием SFTP, выдается ошибка

Error:          Server sent disconnect message
Error:          type 2 (protocol error):
Error:          "Too many authentication failures"
Error:          Could not connect to server
[ 117] Затем я использовал для запуска команды в режиме -v и следующий вывод. Ребята, пожалуйста, помогите мне решить эту проблему. Я полностью сгораю от этого.

OpenSSH_7.9p1, LibreSSL 2.7.3
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to x.x.x.x [x.x.x.x] port 22.
debug1: Connection established.
debug1: identity file mykey.pem type -1
debug1: identity file mykeypem-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH_7.0*,OpenSSH_7.1*,OpenSSH_7.2*,OpenSSH_7.3*,OpenSSH_7.4*,OpenSSH_7.5*,OpenSSH_7.6*,OpenSSH_7.7* compat 0x04000002
debug1: Authenticating to x.x.x.x:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:6NiTFBw2gv2t9lxZJlAxMbNJ7Ih2WcEmp2S3McfuFe0
debug1: Host 'x.x.x.x' is known and matches the ECDSA host key.
debug1: Found key in /Users/myuser/.ssh/known_hosts:1
debug1: rekey after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey after 134217728 blocks
debug1: Will attempt key: mykey.pem  explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Trying private key: mykey.pem
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
ubuntu@x.x.x.x: Permission denied (publickey).
1
задан 30 April 2019 в 01:46

1 ответ

Основной причиной проблемы, с которой я столкнулся, было то, что один из членов моей команды изменил права доступа к каталогу /home/user на 777.

Это все портит.

Правильные разрешения:

/home/user 600
/home/user/.ssh 700
/home/user/.ssh/authorised_keys 0600

Надеюсь, что это будет полезно для других.

0
ответ дан 30 April 2019 в 01:46

Другие вопросы по тегам:

Похожие вопросы: