Host-hopping scripts in Python
I provide telecommute consulting for a company called Crisp Hughes Evans (CHE) in Asheville, North Carolina. They needed a way to download Web logs from Apache, Zope and Plone Web sites, which were developed internally by employees, and Squid Proxy servers, which were running behind firewalls on client LANs that CHE set up. Because CHE believes in minimizing the number of different technologies used, I needed to see if I could download the Web logs reliably without changing the computer environment. Several methods exist to download logs: NFS, SAMBA, HTTP, FTP and so on. But because every computer has SSH installed and running, I decided to test SSH with Expect and my favorite programming language, Python.
What is SSH? SSH is a program used to log in to remote computers and execute commands or to transfer files. SSH also is encrypted. You can find out more information about SSH at www.openSSH.org. I chose SSH because all the computers had SSH, and I was trying to prevent installing new services.
What is Expect? Expect is an interface to automate login sessions of your favorite service (telnet, FTP, SSH and so on). Expect executes commands for you as if it was an interactive login. It can do this because it handles both the input and output when executing the program. In effect, it handles the expected responses of the programs. For example, it could log in as you and change your password for your account.
[ Read more ]
Reading our newsletter every Monday will keep you up-to-date with security news.
Receive a daily digest of the latest security news.