1

The following code is working fine to get output of command execution on remote server for IPv4 using paramiko.SSHClient. But the same code is not working for IPv6 server.

import paramiko
dssh = paramiko.SSHClient()
dssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
dssh.connect("IPv6_Address", username="root", password="orange")
stdin,stdout,stderr=dssh.exec_command("pwd")
print(stdout.read())

and then I tried to use socket connection for IPv6 like below

sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.connect((hostname, port))
t = paramiko.Transport(sock)

but paramiko.Transport has no exec_command.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Python Spark
  • 303
  • 2
  • 6
  • 16

1 Answers1

1

SSHClient.connect has sock parameter:

sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
sock.connect(("IPv6_Address", port))
dssh.connect("IPv6_Address", username="root", password="orange", sock=sock)

Side note: Do not use AutoAddPolicy like that. You lose security by doing so.
See Paramiko "Unknown Server"
.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992