2012-03-29 3 views
1

У меня есть ошибка, когда я подключаюсь к нескольким серверам с помощью Fabric, используя ключи RSA и конфигурационный файл ssh. Мой клиент - снежный леопард 10.6.8 с python 2.7.2, Fabric 1.4.0, ssh (library) 1.7.13. Я использую несколько ключей RSA с парольной фразой (использование без кодовой фразы не является возможным). Я добавил свои кодовые фразы в ssh-add. Я могу ssh для всех моих серверов без проблем. Я добавил env.use_ssh_config = Верно для моего файла fab, чтобы прочитать мой конфигурационный файл ssh.Ошибка Fabric при подключении к нескольким хостам с конфигурационным файлом ssh и ключами RSA

Когда я подключаюсь к одному серверу с ключами RSA (с паролями), все работает нормально.

Но когда я подключаюсь к 2 или более хостам, я продолжаю получать «пароль для входа» для второго сервера.

fab -H server1,server2 test 
[server1] Executing task 'test' 
[server1] run: uname -s 
[server1] out: Linux 

[server2] Executing task 'test' 
[server2] run: uname -s 
[server2] Login password: 

Мой fabfile

from fabric.api import * 
import ssh 
ssh.util.log_to_file("paramiko.log", 10) 

env.use_ssh_config = True 

def test(): 
    run('uname -s') 

Мой SSH конфигурационный файл

Host server1 
HostName xx.xx.xx.xx 
Port 6666 
User AB1 
HashKnownHosts yes 
PreferredAuthentications publickey 
AddressFamily inet  

Host server2 
HostName xx.xx.xx.xx 
Port 6666 
User BC2 
HashKnownHosts yes 
PreferredAuthentications publickey 
AddressFamily inet 

В моем файле конфигурации SSH, я попытался удалить "HashKnownHosts да", но это ничего не меняет что-нибудь.

paramiko.log

DEB [20120329-17:33:30.747] thr=1 ssh.transport: starting thread (client mode): 0x1382350L 
INF [20120329-17:33:30.769] thr=1 ssh.transport: Connected (version 2.0, client OpenSSH_4.3) 
DEB [20120329-17:33:30.786] thr=1 ssh.transport: kex algos:['diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', '[email protected]'] server encrypt:['aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour256', 'arcfour128', 'aes128-cbc', '3des-cbc', 'blowfish-cbc', 'cast128-cbc', 'aes192-cbc', 'aes256-cbc', 'arcfour', '[email protected]'] client mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', '[email protected]', 'hmac-sha1-96', 'hmac-md5-96'] server mac:['hmac-md5', 'hmac-sha1', 'hmac-ripemd160', '[email protected]', 'hmac-sha1-96', 'hmac-md5-96'] client compress:['none', '[email protected]'] server compress:['none', '[email protected]'] client lang:[''] server lang:[''] kex follows?False 
DEB [20120329-17:33:30.786] thr=1 ssh.transport: Ciphers agreed: local=aes128-ctr, remote=aes128-ctr 
DEB [20120329-17:33:30.786] thr=1 ssh.transport: using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes128-ctr, remote aes128-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none 
DEB [20120329-17:33:30.866] thr=1 ssh.transport: Switch to new keys ... 
DEB [20120329-17:33:30.875] thr=2 ssh.transport: Trying SSH agent key ar8298z4c935cde079ef98763678ecc5 
DEB [20120329-17:33:30.935] thr=1 ssh.transport: userauth is OK 
INF [20120329-17:33:31.017] thr=1 ssh.transport: Authentication (publickey) failed. 
DEB [20120329-17:33:31.039] thr=2 ssh.transport: Trying SSH agent key 0273aff478dddddd05378738dhe98798 
DEB [20120329-17:33:31.055] thr=1 ssh.transport: userauth is OK 
INF [20120329-17:33:31.135] thr=1 ssh.transport: Authentication (publickey) successful! 
DEB [20120329-17:33:31.140] thr=2 ssh.transport: [chan 1] Max packet in: 34816 bytes 
DEB [20120329-17:33:31.159] thr=1 ssh.transport: [chan 1] Max packet out: 32768 bytes 
INF [20120329-17:33:31.159] thr=1 ssh.transport: Secsh channel 1 opened. 
DEB [20120329-17:33:31.189] thr=1 ssh.transport: [chan 1] Sesch channel 1 request ok 
DEB [20120329-17:33:31.218] thr=1 ssh.transport: [chan 1] Sesch channel 1 request ok 
DEB [20120329-17:33:31.237] thr=1 ssh.transport: [chan 1] EOF received (1) 
DEB [20120329-17:33:31.237] thr=1 ssh.transport: [chan 1] EOF sent (1) 
DEB [20120329-17:33:31.275] thr=3 ssh.transport: starting thread (client mode): 0x10f9050L 
INF [20120329-17:33:32.126] thr=3 ssh.transport: Connected (version 2.0, client OpenSSH_5.3) 
DEB [20120329-17:33:32.156] thr=3 ssh.transport: kex algos:['diffie-hellman-group-exchange-sha256', 'diffie-hellman-group-exchange-sha1', 'diffie-hellman-group14-sha1', 'diffie-hellman-group1-sha1'] server key:['ssh-rsa', 'ssh-dss'] client encrypt:['blowfish-cbc', 'aes256-cbc', 'aes256-ctr'] server encrypt:['blowfish-cbc', 'aes256-cbc', 'aes256-ctr'] client mac:['hmac-sha1', 'hmac-sha1-96'] server mac:['hmac-sha1', 'hmac-sha1-96'] client compress:['none', '[email protected]m', 'zlib'] server compress:['none', '[email protected]', 'zlib'] client lang:[''] server lang:[''] kex follows?False 
DEB [20120329-17:33:32.156] thr=3 ssh.transport: Ciphers agreed: local=aes256-ctr, remote=aes256-ctr 
DEB [20120329-17:33:32.156] thr=3 ssh.transport: using kex diffie-hellman-group1-sha1; server key type ssh-rsa; cipher: local aes256-ctr, remote aes256-ctr; mac: local hmac-sha1, remote hmac-sha1; compression: local none, remote none 
DEB [20120329-17:33:32.209] thr=3 ssh.transport: Switch to new keys ... 
DEB [20120329-17:33:32.243] thr=2 ssh.transport: Trying SSH agent key ar8298z4c935cde079ef98763678ecc5 
DEB [20120329-17:33:32.307] thr=3 ssh.transport: userauth is OK 
INF [20120329-17:33:32.426] thr=3 ssh.transport: Authentication (publickey) failed. 
DEB [20120329-17:33:32.444] thr=2 ssh.transport: Trying SSH agent key 0273aff478dddddd05378738dhe98798 
DEB [20120329-17:33:32.476] thr=3 ssh.transport: userauth is OK 
INF [20120329-17:33:32.570] thr=3 ssh.transport: Authentication (publickey) failed. 
DEB [20120329-17:33:32.578] thr=2 ssh.transport: Trying SSH agent key 7382deeeee873897883ccc9878972878 
DEB [20120329-17:33:32.608] thr=3 ssh.transport: userauth is OK 
INF [20120329-17:33:32.702] thr=3 ssh.transport: Authentication (publickey) failed. 
DEB [20120329-17:33:32.711] thr=2 ssh.transport: Trying SSH agent key 98792098cccccccccccceeeeeeee9878 
DEB [20120329-17:33:32.743] thr=3 ssh.transport: userauth is OK 
INF [20120329-17:33:32.843] thr=3 ssh.transport: Authentication (publickey) failed. 

SSH-агент ключ 0273aff478dddddd05378738dhe98798 является одинаковым для обоих серверов. Он подключается к первому серверу, но не работает на втором сервере. Я пробовал с разных серверов в разных заказах, но у меня всегда была такая же проблема, что и ткань, запрашивающая пароль для второго сервера.

Как я могу это исправить?

Спасибо

+0

После проверки журналов сервера, я думаю, что нашел проблему. Ткань использует неправильного пользователя, когда пытается подключиться на втором сервере. – Tom

+0

Проблема исправлена, мне просто нужно указать имя пользователя :) – Tom

ответ

1

С опцией use_ssh_config значение ИСТИНА, который должен подобрать имя пользователя. Вы можете проверить его by running these lines в python repl.