In general, I use the python library: asyncssh to execute ssh commands. Here is the code:
@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()) But unfortunately nothing happens and nothing is output to the console ...
I can enter the console without any problems: ssh root@178.79.132.133 Then I enter the password, everything is fine, but it does not work here, where is the error? With paramiko , everything worked well too.
Generally further more. Began vyesnyat. To the server that joins Ubuntu, but for some reason it doesn't work on OpenSUSE.
Began to watch connection logs:
OpenSUSE (to which it turns out to join but not pass authorization):
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 hmac-md5-etm@openssh.com none debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com 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 to which it turned out to join and pass authorization:
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 hmac-md5-etm@openssh.com none debug1: kex: client->server aes128-ctr hmac-md5-etm@openssh.com 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 Tell me what is wrong? What needs to be corrected in the ssh server settings?