bitprophet/ssh — pull request #34 by clarete (2012-08-01 06:27:32+00:00)
Title: Adding support for the ProxyCommand feature

Now, instead of just ignoring the ProxyCommand var, the ssh library is able to retrieve
this configuration from the `~/.ssh/conf` file and use it to proxy the connection between
the client and the SSH server.

This commit introduces the ssh.proxy module that implements the interface required by
the `client.Transport` class. But instead of using sockets, this class writes and reads info
from a peopened program that actually talks with the ssh server.

Given the following ssh config entry:

host comum
User lincoln
hostname comum.org
IdentityFile ~/.ssh/id_rsa
ProxyCommand ssh -q -o StrictHostKeyChecking=no localhost nc %h 22

Here's a simple test case

```python

import ssh
import sys

def test_client(host_name):
conf = ssh.SSHConfig()
conf.parse(open(os.path.expanduser('~/.ssh/config')))
host = conf.lookup(host_name)
client = ssh.SSHClient()
client.load_system_host_keys()
client.connect(
host['hostname'], username=host['user'],
key_filename=host['identityfile'],
proxy_command=host.get('proxycommand')
)
stdin, stdout, stderr = client.exec_command('ls /home')
print stdout.read()
stdin, stdout, stderr = client.exec_command('ls /')
print stdout.read()

if __name__ == '__main__':
test_client(sys.argv[1])
```

Run it with the following comand:
```shell
python example.py comum
```