diff options
author | Olle Lundberg <geek@nerd.sh> | 2012-10-16 16:38:38 +0200 |
---|---|---|
committer | Olle Lundberg <geek@nerd.sh> | 2012-10-16 16:38:38 +0200 |
commit | 7ce9875ed7d3e3738ed775ffda4ded1ce12d35f2 (patch) | |
tree | 5c438d55c856419b3649e370c49022e8dfa7716b | |
parent | d66d75f277cfd49b8adc84498b0b09d71092bd0b (diff) |
Implement support for parsing proxycommand.
-rw-r--r-- | paramiko/config.py | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/paramiko/config.py b/paramiko/config.py index 26a94a12..832f42ef 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -23,6 +23,7 @@ L{SSHConfig}. import fnmatch import os +import re import socket SSH_PORT = 22 @@ -43,6 +44,7 @@ class SSHConfig (object): """ Create a new OpenSSH config object. """ + self._proxyregex = re.compile(r"^(proxycommand)\s*=*\s*(.*)", re.I) self._config = [] def parse(self, file_obj): @@ -58,8 +60,15 @@ class SSHConfig (object): if (line == '') or (line[0] == '#'): continue if '=' in line: - key, value = line.split('=', 1) - key = key.strip().lower() + if not line.lower().startswith('proxycommand'): + key, value = line.split('=', 1) + key = key.strip().lower() + else: + #ProxyCommand have been specified with an equal + # sign. Eat that and split in two groups. + match = self._proxyregex.match(line) + key = match.group(1).lower() + value = match.group(2) else: # find first whitespace, and split there i = 0 @@ -183,7 +192,14 @@ class SSHConfig (object): ('%l', fqdn), ('%u', user), ('%r', remoteuser) - ]} + ], + 'proxycommand': + [ + ('%h', config['hostname']), + ('%p', port), + ('%r', remoteuser) + ] + } for k in config: if k in replacements: for find, replace in replacements[k]: |