SSH по ключу без пароля

Автор simonflex, 04 февраля 2019, 10:39:31

« назад - далее »

0 Пользователи и 1 гость просматривают эту тему.

simonflex

Всем доброго времени суток.
Что-то у меня никак не выходит подключится по SSH с ключами без пароля
Все время запрашивает пароль.
Создал пару ключей на клиенте
ssh-keygen -t rsa -f ~/.ssh/id_rsa_mykey
Скрипт создал 2 ключа: приватный и публичный
~/.ssh/id_rsa_mykey
~/.ssh/id_rsa_mykey.pub

далее скопировал публичный ключ на удаленный сервер
ssh-copy-id -i ~/.ssh/id_rsa_mykey.pub user@server
После этой команды на сервере, в папке пользователя /home/user/.ssh появился файл authorized_keys содержащий публичный ключ.
С клиента подключаюсь ssh -p2222 user@server -i ~/.ssh/id_rsa_mykey
Пробовал разные варианты из гугла, ничего не помогло
Помогите разобраться.
Я всегда с пониманием оцениваю любую помощь !

endru

а зачем указывать путь к файлу постоянно?
ssh-keygen -t rsa
ssh-copy-id user@server
ssh user@server

если авторизация не проходит, добавляешь ключ -v и приводишь дебаг информацию о подключении сюда.
ssh -v user@server

simonflex

Цитата: endru от 04 февраля 2019, 11:14:24дебаг информацию о подключении сюда
Подскажите как вывести verbose в файл (ssh -v user@server)
Я всегда с пониманием оцениваю любую помощь !

endru

можно стандартным перенаправлением вывода:
ssh -v user@server 2> ssh-log.txt

simonflex

Цитата: endru от 04 февраля 2019, 12:05:57можно стандартным перенаправлением вывода:
не получилось, созданный файл пустой
сделал по другому
ssh -v user@server 2>file Перенаправление ввода/вывода
Я всегда с пониманием оцениваю любую помощь !

simonflex

это лог до ввода пароля на удаленном сервере
OpenSSH_7.4p1 Debian-10+deb9u4, OpenSSL 1.0.2q  20 Nov 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 93.XX.XX.9 [93.XX.XX.9] port 2222.
debug1: Connection established.
debug1: identity file /home/simon/.ssh/id_rsa_mykey type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/simon/.ssh/id_rsa_mykey-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 93.XX.XX.9:2222 as 'user677'
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:w3IyOPWgdKzikF+d432E8ByXX9c+OHEUkY6y+h6gBD0
debug1: Host '[93.XX.XX.9]:2222' is known and matches the ECDSA host key.
debug1: Found key in /home/simon/.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: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/simon/.ssh/id_rsa_mykey
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password

это лог после ввода пароля на удаленном сервере
OpenSSH_7.4p1 Debian-10+deb9u4, OpenSSL 1.0.2q  20 Nov 2018
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 93.XX.XX.9 [93.XX.XX.9] port 2222.
debug1: Connection established.
debug1: identity file /home/simon/.ssh/id_rsa_mykey type 1
debug1: key_load_public: No such file or directory
debug1: identity file /home/simon/.ssh/id_rsa_mykey-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.4p1 Debian-10+deb9u4
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.4
debug1: match: OpenSSH_7.4 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 93.XX.XX.9:2222 as 'user677'
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:w3IyOPWgdKzikF+d432E8ByXX9c+OHEUkY6y+h6gBD0
debug1: Host '[93.XX.XX.9]:2222' is known and matches the ECDSA host key.
debug1: Found key in /home/simon/.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: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: gssapi-keyex
debug1: No valid Key exchange context
debug1: Next authentication method: gssapi-with-mic
debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug1: Unspecified GSS failure.  Minor code may provide more information
No Kerberos credentials available (default cache: FILE:/tmp/krb5cc_1000)

debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/simon/.ssh/id_rsa_mykey
debug1: Authentications that can continue: publickey,gssapi-keyex,gssapi-with-mic,password
debug1: Next authentication method: password
debug1: Authentication succeeded (password).
Authenticated to 93.XX.XX.9 ([93.XX.XX.9]:2222).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: pledge: network
debug1: client_input_global_request: rtype hostkeys-00@openssh.com want_reply 0
debug1: Remote: Ignored authorized keys: bad ownership or modes for directory /var/www/user677/data
debug1: Sending environment.
debug1: Sending env LANG = ru_RU.UTF-8
debug1: Last login 4 Feb
Я всегда с пониманием оцениваю любую помощь !

simonflex

Уж не знаю в чем проблема, все тоже самое проделывал с другими хостами и небыло проблем. Здесь утверждают что все у них настроено должным образом, и другие клиенты подключаются без проблем. Или какой-то ишачина великий специалист сетевик не хочет ничего смотреть, потому что он гений-баран!
Я всегда с пониманием оцениваю любую помощь !

simonflex

Проблема решена. Там видимо с математикой у людей туго. 4+2+1 будет 7 (семь) а у них 777
Я всегда с пониманием оцениваю любую помощь !