diff options
author | Jeff Forcier <jeff@bitprophet.org> | 2022-04-25 10:42:50 -0400 |
---|---|---|
committer | Jeff Forcier <jeff@bitprophet.org> | 2022-04-25 10:43:11 -0400 |
commit | f325261699a1989d7aef1a62e3b3dab96f25d237 (patch) | |
tree | 7664e85d9c7d3f1daa50baadc2b36eac63336023 | |
parent | 9b22c28a02e5ae0291857a7fb9051cf942280731 (diff) |
Massage #1951 a bit
- changelog
- test
- tilde makes no sense here (ProxyJump is only ever [user@]host[:port] syntax) so removed it
-rw-r--r-- | paramiko/config.py | 2 | ||||
-rw-r--r-- | sites/www/changelog.rst | 2 | ||||
-rw-r--r-- | tests/test_config.py | 19 |
3 files changed, 22 insertions, 1 deletions
diff --git a/paramiko/config.py b/paramiko/config.py index f6570271..081d0d68 100644 --- a/paramiko/config.py +++ b/paramiko/config.py @@ -64,7 +64,7 @@ class SSHConfig(object): "hostname": ["%h"], "identityfile": ["%C", "~", "%d", "%h", "%l", "%u", "%r"], "proxycommand": ["~", "%h", "%p", "%r"], - "proxyjump": ["~", "%h", "%p", "%r"], + "proxyjump": ["%h", "%p", "%r"], # Doesn't seem worth making this 'special' for now, it will fit well # enough (no actual match-exec config key to be confused with). "match-exec": ["%C", "%d", "%h", "%L", "%l", "%n", "%p", "%r", "%u"], diff --git a/sites/www/changelog.rst b/sites/www/changelog.rst index eda7d1e5..62433426 100644 --- a/sites/www/changelog.rst +++ b/sites/www/changelog.rst @@ -2,6 +2,8 @@ Changelog ========= +- :feature:`1951` Add SSH config token expansion (eg ``%h``, ``%p``) when + parsing ``ProxyJump`` directives. Patch courtesy of Bruno Inec. - :bug:`1964` (via :issue:`2024` as also reported in :issue:`2023`) `~paramiko.pkey.PKey` instances' ``__eq__`` did not have the usual safety guard in place to ensure they were being compared to another ``PKey`` object, diff --git a/tests/test_config.py b/tests/test_config.py index b46dc7b4..45fb262d 100644 --- a/tests/test_config.py +++ b/tests/test_config.py @@ -207,6 +207,25 @@ Host test assert got == expected @patch("paramiko.config.getpass") + def test_proxyjump_token_expansion(self, getpass): + getpass.getuser.return_value = "gandalf" + config = SSHConfig.from_text( + """ +Host justhost + ProxyJump jumpuser@%h +Host userhost + ProxyJump %r@%h:222 +Host allcustom + ProxyJump %r@%h:%p +""" + ) + assert config.lookup("justhost")["proxyjump"] == "jumpuser@justhost" + assert config.lookup("userhost")["proxyjump"] == "gandalf@userhost:222" + assert ( + config.lookup("allcustom")["proxyjump"] == "gandalf@allcustom:22" + ) + + @patch("paramiko.config.getpass") def test_controlpath_token_expansion(self, getpass, socket): getpass.getuser.return_value = "gandalf" config = SSHConfig.from_text( |