From 22054fd8be788fccbc06ca6d665425a1106e4cb0 Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Mon, 3 Feb 2025 10:37:47 -0500 Subject: [PATCH 1/3] Add the option to connect to a server using the domain to make it easier when connecting through Akamai Zero Trust Client. --- linodecli/plugins/ssh.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/linodecli/plugins/ssh.py b/linodecli/plugins/ssh.py index 2ed53cbdb..1536ad0bb 100644 --- a/linodecli/plugins/ssh.py +++ b/linodecli/plugins/ssh.py @@ -50,6 +50,11 @@ def call(args, context): # pylint: disable=too-many-branches action="store_true", help="If given, uses the Linode's SLAAC address for SSH.", ) + parser.add_argument( + "-d", + action="store_true", + help="If given, uses the Lindoe's domain name for SSH", + ) parsed, args = parser.parse_known_args(args) @@ -147,4 +152,9 @@ def parse_target_address( if ip.startswith("192.168"): continue + if getattr( + parsed, "d" + ): + ip = ip.replace(".", "-") + ".ip.linodeusercontent.com" + return ip From 178cd021c56d33f9db83a8b60319189a954356f4 Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Mon, 3 Feb 2025 11:47:05 -0500 Subject: [PATCH 2/3] Add unit test --- tests/unit/test_plugin_ssh.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/unit/test_plugin_ssh.py b/tests/unit/test_plugin_ssh.py index 92471fde9..216734da0 100644 --- a/tests/unit/test_plugin_ssh.py +++ b/tests/unit/test_plugin_ssh.py @@ -187,11 +187,17 @@ def test_parse_target_address(): "ipv6": "c001:d00d::1337/128", } - test_namespace = argparse.Namespace(**{"6": False}) + test_namespace = argparse.Namespace(**{"6": False, "d": False}) address = plugin.parse_target_address(test_namespace, test_target) assert address == "123.123.123.123" + # Hack to work around invalid key + setattr(test_namespace, "d", True) + + address = plugin.parse_target_address(test_namespace, test_target) + assert address == "123-123-123-123.ip.linodeusercontent.com" + # Hack to work around invalid key setattr(test_namespace, "6", True) From 812f934fcd8bb0339125bad83d1ea3e151d024bb Mon Sep 17 00:00:00 2001 From: James Rouzier Date: Tue, 11 Feb 2025 16:23:05 -0500 Subject: [PATCH 3/3] format --- linodecli/plugins/ssh.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/linodecli/plugins/ssh.py b/linodecli/plugins/ssh.py index 1536ad0bb..c644f7993 100644 --- a/linodecli/plugins/ssh.py +++ b/linodecli/plugins/ssh.py @@ -152,9 +152,7 @@ def parse_target_address( if ip.startswith("192.168"): continue - if getattr( - parsed, "d" - ): + if getattr(parsed, "d"): ip = ip.replace(".", "-") + ".ip.linodeusercontent.com" return ip