The basics of my ssh client are this:
- prompt for username and password - ssh keys not required (although I would like to add support for using them if available in the future)
- interactive use - I often want to look at things, which leads me to want to look at other things; in other words, I don't want to be constrained by having a list of commands to execute up front
- parallel - I have a bunch of commands and a bunch of machines, a simple loop executing each command on each machine isn't going to cut it
I started with the former, but soon found that if you only send commands, you have practically no environment setup (that is all done in the shell, remember...). So, despite the difficulties in dealing with the terminal, that is what this implementation does.
A terminal based solution has its own issues, the line buffering of output from each host has to be dealt with to avoid interleaved garbage as the results of each command. But in the end that wasn't too hard.
In the end, usage is simple, cut-n-paste the code, save it as bssh.py and run something like:
./bssh.py host1 host2 host3 host4Enter a username and password at the prompts, and away you go, just enter commands as you would with any other shell. You will of course need paramiko and its dependency pycrypto installed and available.