diff options
-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( |