You need to create ProxyCommand
(a socket-like object) and pass it to client.connect()
import paramiko
conf = paramiko.SSHConfig()
conf.parse(open('/home/user/.ssh/config'))
host = conf.lookup('host')
print host
proxy = paramiko.ProxyCommand(host['proxycommand'])
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(host["hostname"], username=host["user"], password='test', sock=proxy)
client.close()
Docs for connect()
method. Note timeout
parameter. It's always a good idea to specify it if you are doing some automation.