Вообщем использую python библиотеку: asyncssh для выполнения команд по ssh. Вот код:
@asyncio.coroutine
def run_client():
conn, client = yield from asyncssh.connection("178.79.132.133", username="root", password="1234")
with conn:
stdin, stdout, stderr = yield from conn.open_session('echo "Hello!"')
output = yield from stdout.read()
print(output, end='')
status = stdout.channel.get_exit_status()
if status:
print('Program exited with status %d' % status, file=sys.stderr)
else:
print('Program exited successfully')
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(run_client())
Но к сожалению ничего не происходит и в консоль ничего не выводиться...
В консоли без проблем могу зайти:
ssh [email protected]
Потом ввожу пароль, все хорошо, а тут не работает, где ошибка? При помощи paramiko
тоже все хорошо работало.
Вообщем дальше больше. Стал выеснять. К серверу, который на Ubuntu присоединяется, а вот на OpenSUSE почему-то не получается.
Стал смотреть логи соединения:
OpenSUSE (к которому получается присоединиться но не проходит авторизация):
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 178.79.133.135 [178.79.133.135] port 22.
debug1: Connection established.
debug1: identity file /home/ivan/.ssh/id_rsa type 1
debug1: identity file /home/ivan/.ssh/id_rsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_dsa type -1
debug1: identity file /home/ivan/.ssh/id_dsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_ecdsa type -1
debug1: identity file /home/ivan/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_ed25519 type -1
debug1: identity file /home/ivan/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.2
debug1: match: OpenSSH_6.2 pat OpenSSH* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA f2:1c:bc:f8:a5:ae:15:02:5d:a1:25:d2:e6:05:73:74
debug1: Host '178.79.133.135' is known and matches the ECDSA host key.
debug1: Found key in /home/ivan/.ssh/known_hosts:2
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ivan/.ssh/id_rsa
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Trying private key: /home/ivan/.ssh/id_dsa
debug1: Trying private key: /home/ivan/.ssh/id_ecdsa
debug1: Trying private key: /home/ivan/.ssh/id_ed25519
debug1: Next authentication method: keyboard-interactive
Ubuntu к которому получилось присоедениться и пройти авторизация:
OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 192.168.0.24 [192.168.0.24] port 22.
debug1: Connection established.
debug1: identity file /home/ivan/.ssh/id_rsa type 1
debug1: identity file /home/ivan/.ssh/id_rsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_dsa type -1
debug1: identity file /home/ivan/.ssh/id_dsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_ecdsa type -1
debug1: identity file /home/ivan/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/ivan/.ssh/id_ed25519 type -1
debug1: identity file /home/ivan/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_6.6.1p1 Ubuntu-2ubuntu2
debug1: match: OpenSSH_6.6.1p1 Ubuntu-2ubuntu2 pat OpenSSH_6.6.1* compat 0x04000000
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr [email protected] none
debug1: kex: client->server aes128-ctr [email protected] none
debug1: sending SSH2_MSG_KEX_ECDH_INIT
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ECDSA ab:80:e4:3f:33:d3:06:cd:22:c8:c6:da:84:83:97:62
debug1: Host '192.168.0.24' is known and matches the ECDSA host key.
debug1: Found key in /home/ivan/.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /home/ivan/.ssh/id_rsa
debug1: Authentications that can continue: publickey,password
debug1: Trying private key: /home/ivan/.ssh/id_dsa
debug1: Trying private key: /home/ivan/.ssh/id_ecdsa
debug1: Trying private key: /home/ivan/.ssh/id_ed25519
debug1: Next authentication method: password
Скажите, что не так? Что нужно поправить в настройках сервера ssh?