Новый пятничный про openssh
ru_root — 06.07.2016
В общем "суть токова".Два админа голову уже сломали, поломайте и вы.
Есть несколько серверов (для нашего примера хватит 3, хотя их больше), с Centos 7.2, с последними обновлениями.
Между серверами настроена авторизация по ключам ssh, c таким конфигом:
Port 2222
AcceptEnv LANG LC_*
ChallengeResponseAuthentication no
PasswordAuthentication no
PermitRootLogin yes
PrintMotd no
Subsystem sftp /usr/libexec/openssh/sftp-server
UsePAM yes
X11Forwarding yes
AllowUsers root vasya petya
На всех серверах раскидан один и тот же id_rsa, зашифрованный пассфразой.
На всех серверах лежат одинаковые authorized_keys.
Selinux отключен.
Файлы все сверены через md5, в том числе бинарники openssh.
Права на ключи и саму папку /root/.ssh стоят верные (600/700 соответственно).
Проблема: с одного из серверов нельзя зайти на другие два.
Все остальные комбинации между собой работают.
На сервере откуда идем при этом выдается ошибка Permission denied (publickey).
Пассфраза даже не запрашивается.
Дебаг на сервере откуда пытаемся:
debug2: key: /root/.ssh/id_rsa (0x55f2d9498b60), explicit
debug1: Authentications that can continue: publickey
debug3: start over, passed a different list publickey
debug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,password
debug3: authmethod_lookup publickey
debug3: remaining preferred: keyboard-interactive,password
debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /root/.ssh/id_rsa
debug3: send_pubkey_test
debug2: we sent a publickey packet, wait for reply
debug1: Authentications that can continue: publickey
debug2: we did not send a packet, disable method
debug1: No more authentication methods to try.
Дебаг на сервере куда идем:
debug1: trying public key file /root/.ssh/authorized_keys
debug1: fd 4 clearing O_NONBLOCK
debug2: key not found
debug1: restore_uid: 0/0
debug1: temporarily_use_uid: 0/0 (e=0/0)
debug1: trying public key file /root/.ssh/authorized_keys2
debug1: fd 4 clearing O_NONBLOCK
debug2: key not found
debug1: restore_uid: 0/0
debug3: mm_answer_keyallowed: key 0x7f57a5fbb7d0 is not allowed
Failed publickey for root from 10.10.10.10 port 47694 ssh2: RSA ec:6a:fc:3a:93:83:23:bf:12:c4:55:51:88:bc:2e:9e
Вывод strace:
write(2, "debug1: trying public key file /"..., 59debug1: trying public key file /root/.ssh/authorized_keys
) = 59
open("/root/.ssh/authorized_keys", O_RDONLY|O_NONBLOCK) = 4
fstat(4, {st_mode=S_IFREG|0600, st_size=1739, ...}) = 0
fcntl(4, F_GETFL) = 0x8800 (flags O_RDONLY|O_NONBLOCK|O_LARGEFILE)
write(2, "debug1: fd 4 clearing O_NONBLOCK"..., 34debug1: fd 4 clearing O_NONBLOCK
) = 34
fcntl(4, F_SETFL, O_RDONLY|O_LARGEFILE) = 0
fcntl(4, F_GETFL) = 0x8000 (flags O_RDONLY|O_LARGEFILE)
fstat(4, {st_mode=S_IFREG|0600, st_size=1739, ...}) = 0
lstat("/root", {st_mode=S_IFDIR|0550, st_size=4096, ...}) = 0
lstat("/root/.ssh", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
lstat("/root/.ssh/authorized_keys", {st_mode=S_IFREG|0600, st_size=1739, ...}) = 0
lstat("/root", {st_mode=S_IFDIR|0550, st_size=4096, ...}) = 0
stat("/root/.ssh", {st_mode=S_IFDIR|0700, st_size=4096, ...}) = 0
stat("/root", {st_mode=S_IFDIR|0550, st_size=4096, ...}) = 0
fstat(4, {st_mode=S_IFREG|0600, st_size=1739, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f2439e75000
read(4, "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAA"..., 4096) = 1739
read(4, "", 4096) = 0
write(2, "debug2: key not found\r\n", 23debug2: key not found
Решение:
rm -f /root/.ssh/id_rsa.pub
Паблик был левый.
А при отсутствии, он восстанавливается из закрытого ключа.
ПАСИБИЩЕ! :)
|
|
</> |
Основные инструменты агентства по управлению репутацией 
