From 37571f7e3df5b057d0a7b4fc637bea39e6715714 Mon Sep 17 00:00:00 2001 From: ntaken <71373110+ntaken@users.noreply.github.com> Date: Fri, 25 Sep 2020 11:54:08 +0200 Subject: [PATCH] Update ssh_connect.py changes to ssh_config.py to support a global ssh_config for users #660 https://github.com/liftoff/GateOne/pull/660 by edwins --- .../plugins/ssh/scripts/ssh_connect.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py b/gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py index 5fc32836..6e6537b2 100755 --- a/gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py +++ b/gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py @@ -300,7 +300,10 @@ def openssh_connect( users_ssh_dir = os.path.join(os.environ['USERPROFILE'], '.ssh') if not os.path.exists(users_ssh_dir): mkdir_p(users_ssh_dir) - ssh_config_path = os.path.join(users_ssh_dir, 'config') + if config: + ssh_config_path = config + else: + ssh_config_path = os.path.join(users_ssh_dir, 'config') if not os.path.exists(ssh_config_path): # Create it (an empty one so ssh doesn't error out) with open(ssh_config_path, 'w') as f: @@ -724,6 +727,11 @@ def main(): "credentials only (you probably want to use --default_host and " "--default_port as well).") ) + parser.add_option("--config", + dest="config", + default=None, + help=_("Provide an ssh config file location") + ) (options, args) = parser.parse_args() if options.logo_path: options.logo = True @@ -743,6 +751,7 @@ def main(): identities=parsed.get('identities', []), additional_args=options.additional_args, socket=options.socket, + config=options.config, debug=parsed.get('debug', False) ) elif len(args) == 2: # No port given, assume 22 @@ -751,7 +760,8 @@ def main(): sshfp=options.sshfp, randomart=options.randomart, additional_args=options.additional_args, - socket=options.socket + socket=options.socket, + config=options.config ) elif len(args) == 3: openssh_connect(args[0], args[1], args[2], @@ -759,7 +769,8 @@ def main(): sshfp=options.sshfp, randomart=options.randomart, additional_args=options.additional_args, - socket=options.socket + socket=options.socket, + config=options.config ) except Exception: pass # Something ain't right. Try the interactive entry method... @@ -895,6 +906,7 @@ def main(): identities=identities, additional_args=options.additional_args, socket=options.socket, + config=options.config, debug=debug ) elif protocol == 'telnet':