March 2019
Beginner
490 pages
12h 40m
English
If you want to run several commands on the remote host using paramiko, but you encounter the problem that the ssh session is closed when you execute a command, give an exception related with SSH session not active:
paramiko.ssh_exception.SSHException: SSH session not active
To solve this, you can implement an interactive shell using paramiko; that way, the channel does not close after a command is executed in the remote shell.
After creating the SSH client, using connect, you can use the invoke_shell() method, and it will open a channel that it doesn't close after you send something through it.
You can find the following code in the ssh_interactive_shell.py file:
#!/usr/bin/env python3import paramiko ...
Read now
Unlock full access