Skip to content

Instantly share code, notes, and snippets.

@curzona
Created April 21, 2014 03:45
Show Gist options
  • Save curzona/11131661 to your computer and use it in GitHub Desktop.
Save curzona/11131661 to your computer and use it in GitHub Desktop.
Multiple command shell session with paramiko
import paramiko
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect('HOST', port=22, username='USERNAME', password='PASSWORD')
channel = client.get_transport().open_session()
channel.invoke_shell()
while channel.recv_ready():
channel.recv(1024)
channel.sendall("pwd\n")
print channel.recv(1024)
channel.sendall("cd..\n")
channel.sendall("pwd\n")
print channel.recv(1024)
@Iconic505
Copy link

Works well thanks a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment