Skip to content

A simple and hack way to remember current path after a series of commands like "cd xx", instead of use invoke_shell().

Notifications You must be signed in to change notification settings

GreyBoyka/paramiko-sshclient-session

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

paramiko-sshclient-session

A simple and hack way to remember current path after a series of commands like "cd xx", instead of use invoke_shell().

requires paramiko, install:

pip3 install paramiko

example:

from paramiko import Transport
from sshclient_session import SSHClientSession


def main():
    trans = Transport(("192.168.1.2", 22))
    trans.connect(username="root", password="password")
    client = SSHClientSession()
    client._transport = trans
    
    client.exec_command('pwd')               # path: /root
    client.exec_command('cd /home')
    client.exec_command('pwd')               # path: /home
    client.close()

if __name__ == '__main__':
    main()

About

A simple and hack way to remember current path after a series of commands like "cd xx", instead of use invoke_shell().

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages