summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorOlle Lundberg <geek@nerd.sh>2012-10-16 16:38:38 +0200
committerOlle Lundberg <geek@nerd.sh>2013-02-28 12:11:41 +0100
commitac1310c4a171587ae8fd15268a1981eaf139be57 (patch)
tree5aa5d3b6508ed0c2cb76842dd3e620ad1264b5f8
parentb3d5156019566c972a3dbbea851cffed3cf08514 (diff)
Implement support for parsing proxycommand.
-rw-r--r--paramiko/config.py66
1 files changed, 42 insertions, 24 deletions
diff --git a/paramiko/config.py b/paramiko/config.py
index a31dffc1..e9c1aaff 100644
--- a/paramiko/config.py
+++ b/paramiko/config.py
@@ -82,6 +82,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):
@@ -97,6 +98,7 @@ class SSHConfig (object):
if (line == '') or (line[0] == '#'):
continue
if '=' in line:
+<<<<<<< HEAD
# Ensure ProxyCommand gets properly split
if line.lower().strip().startswith('proxycommand'):
match = proxy_re.match(line)
@@ -104,6 +106,20 @@ class SSHConfig (object):
else:
key, value = line.split('=', 1)
key = key.strip().lower()
+||||||| merged common ancestors
+ 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)
+>>>>>>> Implement support for parsing proxycommand.
else:
# find first whitespace, and split there
i = 0
@@ -209,30 +225,32 @@ class SSHConfig (object):
host = socket.gethostname().split('.')[0]
fqdn = LazyFqdn(self)
homedir = os.path.expanduser('~')
- replacements = {
- 'controlpath': [
- ('%h', config['hostname']),
- ('%l', fqdn),
- ('%L', host),
- ('%n', hostname),
- ('%p', port),
- ('%r', remoteuser),
- ('%u', user)
- ],
- 'identityfile': [
- ('~', homedir),
- ('%d', homedir),
- ('%h', config['hostname']),
- ('%l', fqdn),
- ('%u', user),
- ('%r', remoteuser)
- ],
- 'proxycommand': [
- ('%h', config['hostname']),
- ('%p', port),
- ('%r', remoteuser),
- ],
- }
+ replacements = {'controlpath':
+ [
+ ('%h', config['hostname']),
+ ('%l', fqdn),
+ ('%L', host),
+ ('%n', hostname),
+ ('%p', port),
+ ('%r', remoteuser),
+ ('%u', user)
+ ],
+ 'identityfile':
+ [
+ ('~', homedir),
+ ('%d', homedir),
+ ('%h', config['hostname']),
+ ('%l', fqdn),
+ ('%u', user),
+ ('%r', remoteuser)
+ ],
+ 'proxycommand':
+ [
+ ('%h', config['hostname']),
+ ('%p', port),
+ ('%r', remoteuser)
+ ]
+ }
for k in config:
if k in replacements: