Emulate an Interactive SSH client using Paramiko / Twisted
Clash Royale CLAN TAG#URR8PPP
Emulate an Interactive SSH client using Paramiko / Twisted
I need to emulate SSH client and log the entered commands.
I have followed different links but most of the examples are related to automating tasks. For testing purpose, I need to emulate an Interative SSH Session and log commands.
Note: Paramiko is not mandatory. Twisted resources are much appreciated
1 Answer
1
Use Channel.get_pty
and Channel.invoke_shell
to simulate an interactive SSH terminal session.
Channel.get_pty
Channel.invoke_shell
sshClient = paramiko.SSHClient()
sshClient.connect(host, username=user, password=pass)
channel = sshClient.get_transport().open_session()
# Open interactive SSH session
channel.get_pty()
channel.invoke_shell()
print('Executing command 1')
channel.send('command 1n')
print('Executing command 2')
channel.send('command 2n')
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.