LinuxForum.Fans
Тема

ssh клиент не подхватывает ключ id_rsa

Автор: v4567 3 сообщений 783 просмотров
02.01.2022 02:51 #437106

Здравствуйте форумчане.

Впервые столкнулся с такой проблемой.
Дистрибутив на сервере и на клиенте devuan - ветка debian.
На сервере запущен ssh сервер в котором отключена авторизация по паролю и включена авторизация по ключу.

С клиента под управлением windows, с putty прекрасно подключаюсь по ключу. Предварительно для putty преобразовав ключ id_rsa

С linux, ssh клиентом не могу подключиться. ssh клиент не использует ключ id_rsa а пытается подключиться по паролю и получает отказ в подключении.

В консоле работаю от рута.

Вот клиентский файл /etc/ssh/ssh_config

Показать



# This is the ssh client system-wide configuration file. See
# ssh_config(5) for more information. This file provides defaults for
# users, and the values can be changed in per-user configuration files
# or on the command line.

# Configuration data is parsed as follows:
# 1. command line options
# 2. user-specific file
# 3. system-wide file
# Any configuration value is only changed the first time it is set.
# Thus, host-specific definitions should be at the beginning of the
# configuration file, and defaults at the end.

# Site-wide defaults for some commonly used options. For a comprehensive
# list of available options, their meanings and defaults, please see the
# ssh_config(5) man page.


#Host *
# ForwardAgent no
# ForwardX11 no
# ForwardX11Trusted yes
# RhostsRSAAuthentication no
# RSAAuthentication yes
# PasswordAuthentication yes
# HostbasedAuthentication no
# GSSAPIAuthentication no
# GSSAPIDelegateCredentials no
# GSSAPIKeyExchange no
# GSSAPITrustDNS no
# BatchMode no
# CheckHostIP yes
# AddressFamily any
# ConnectTimeout 0
# StrictHostKeyChecking ask
# IdentityFile ~/.ssh/identity
# IdentityFile ~/.ssh/id_rsa
# IdentityFile ~/.ssh/id_dsa
# IdentityFile ~/.ssh/id_ecdsa
# IdentityFile ~/.ssh/id_ed25519
# Port 22
# Protocol 2
# Cipher 3des
# Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cb
# MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
# EscapeChar ~
# Tunnel no
# TunnelDevice any:any
# PermitLocalCommand no
# VisualHostKey no
# ProxyCommand ssh -q -W %h:%p gateway.example.com
# RekeyLimit 1G 1h
## SendEnv LANG LC_*
## HashKnownHosts yes
## GSSAPIAuthentication yes

Host gt
HostName XXXXXX
Port XXXXX
User XXXXXXX
Protocol 2
BatchMode yes
CheckHostIP no
PasswordAuthentication no
RSAAuthentication yes
IdentityFile /root/.ssh/id_rsa

Вот вывод команды
strace -vf -e trace=open -o /root/ssh.txt ssh -vvv gt

OpenSSH_7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u 20 Dec 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 58: Applying options for gt
debug2: resolving "XXXXX" port XXXX
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to XXXXX [XXXXXXXX] port XXXX.
debug1: connect to address XXXXXX port XXXX: Connection refused
ssh: connect to host XXXXXXX port XXXXX: Connection refused

Вот файл /root/ssh.txt

Показать


13672 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libselinux.so.1", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/x86_64-linux-gnu/libcrypto.so.1.0.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libdl.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libz.so.1", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libresolv.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libpcre.so.3", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/x86_64-linux-gnu/libkrb5.so.3", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/x86_64-linux-gnu/libk5crypto.so.3", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libcom_err.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/x86_64-linux-gnu/libkrb5support.so.0", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libkeyutils.so.1", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libpthread.so.0", O_RDONLY|O_CLOEXEC) = 3
13672 open("/proc/filesystems", O_RDONLY) = 3
13672 open("/dev/null", O_RDWR) = 3
13672 open("/proc/13672/fd", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3
13672 open("/etc/nsswitch.conf", O_RDONLY|O_CLOEXEC) = 3
13672 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libnss_compat.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libnsl.so.1", O_RDONLY|O_CLOEXEC) = 3
13672 open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libnss_nis.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/lib/x86_64-linux-gnu/libnss_files.so.2", O_RDONLY|O_CLOEXEC) = 3
13672 open("/etc/passwd", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
13672 open("/usr/lib/ssl/openssl.cnf", O_RDONLY) = 3
13672 open("/root/.ssh/config", O_RDONLY) = -1 ENOENT (No such file or directory)
13672 open("/etc/ssh/ssh_config", O_RDONLY) = 3
13672 open("/dev/urandom", O_RDONLY|O_NOCTTY|O_NONBLOCK) = 3
13672 +++ exited with 255 +++

Как видно из этого файла ssh клиент не обращается к файлу ключей
/root/.ssh/id_rsa

Если кто знает в чём причина помогите пожалуйста.
За помощь заранее благодарен!

04.01.2022 10:49 #437111

Разобрался в чём причина была.
В ip адресе не правильно написал последние цифры, написал 190, а надо было 171.
А так как я это алиасом в ~/.bashrc написал и всё время в командной строке набирал алиас, то и не соединялось.
Ситуация получалась следующая, ssh клиент посылал syn запрос (самый первый пакет), а в ответ получал сброс соединения, поэтому дальнейший подхват ключей был бессмысленный, он соответственно и писал отказано в соединении.
Я понял это совершенно случайно, в результате многочисленных экспериментов, когда полез в файл ~/.bashrc,
хотя и смотрел tcpdump-пом на пакеты. Вот что значит плохое знание мат. части, надо было сообразить сразу когда посмотрел на пакеты tcpdump-пом.

Войдите или зарегистрируйтесь, чтобы ответить.