diff options
author | Jason Brand <jbrand42@users.noreply.github.com> | 2022-02-16 00:22:37 +0000 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2022-03-11 18:33:50 -0500 |
commit | f6342fc5f00b48e679e7c2c3579b1b27d94ffc1f (patch) | |
tree | e57a2033adf50cc1ef48155cd061a2446de12d1c /paramiko/config.py | |
parent | 3f3451fd46353fa173f6c083b1c38438d04a68ea (diff) | |
download | paramiko-f6342fc5f00b48e679e7c2c3579b1b27d94ffc1f.tar.gz |
Prettify, add %C as acceptable controlpath token, mock gethostname
Diffstat (limited to 'paramiko/config.py')
-rw-r--r-- | paramiko/config.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/paramiko/config.py b/paramiko/config.py index 27fdca4f..c2a58e4e 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -60,7 +60,7 @@ class SSHConfig(object): # TODO: do a full scan of ssh.c & friends to make sure we're fully # compatible across the board, e.g. OpenSSH 8.1 added %n to ProxyCommand. TOKENS_BY_CONFIG_KEY = { - "controlpath": ["%h", "%l", "%L", "%n", "%p", "%r", "%u"], + "controlpath": ["%C", "%h", "%l", "%L", "%n", "%p", "%r", "%u"], "hostname": ["%h"], "identityfile": ["~", "%d", "%h", "%l", "%u", "%r"], "proxycommand": ["~", "%h", "%p", "%r"], @@ -433,13 +433,11 @@ class SSHConfig(object): local_hostname = socket.gethostname().split(".")[0] local_fqdn = LazyFqdn(config, local_hostname) homedir = os.path.expanduser("~") + tohash = local_hostname + target_hostname + repr(port) + remoteuser # The actual tokens! replacements = { # TODO: %%??? - "%C": sha1((local_hostname + - target_hostname + - str(port) + - remoteuser).encode("utf-8")).hexdigest(), + "%C": sha1(tohash.encode()).hexdigest(), "%d": homedir, "%h": configured_hostname, # TODO: %i? |