Skip to content

Commit 37571f7

Browse files
authored
Update ssh_connect.py
changes to ssh_config.py to support a global ssh_config for users liftoff#660 liftoff#660 by edwins
1 parent 654c1f1 commit 37571f7

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,10 @@ def openssh_connect(
300300
users_ssh_dir = os.path.join(os.environ['USERPROFILE'], '.ssh')
301301
if not os.path.exists(users_ssh_dir):
302302
mkdir_p(users_ssh_dir)
303-
ssh_config_path = os.path.join(users_ssh_dir, 'config')
303+
if config:
304+
ssh_config_path = config
305+
else:
306+
ssh_config_path = os.path.join(users_ssh_dir, 'config')
304307
if not os.path.exists(ssh_config_path):
305308
# Create it (an empty one so ssh doesn't error out)
306309
with open(ssh_config_path, 'w') as f:
@@ -724,6 +727,11 @@ def main():
724727
"credentials only (you probably want to use --default_host and "
725728
"--default_port as well).")
726729
)
730+
parser.add_option("--config",
731+
dest="config",
732+
default=None,
733+
help=_("Provide an ssh config file location")
734+
)
727735
(options, args) = parser.parse_args()
728736
if options.logo_path:
729737
options.logo = True
@@ -743,6 +751,7 @@ def main():
743751
identities=parsed.get('identities', []),
744752
additional_args=options.additional_args,
745753
socket=options.socket,
754+
config=options.config,
746755
debug=parsed.get('debug', False)
747756
)
748757
elif len(args) == 2: # No port given, assume 22
@@ -751,15 +760,17 @@ def main():
751760
sshfp=options.sshfp,
752761
randomart=options.randomart,
753762
additional_args=options.additional_args,
754-
socket=options.socket
763+
socket=options.socket,
764+
config=options.config
755765
)
756766
elif len(args) == 3:
757767
openssh_connect(args[0], args[1], args[2],
758768
command=options.command,
759769
sshfp=options.sshfp,
760770
randomart=options.randomart,
761771
additional_args=options.additional_args,
762-
socket=options.socket
772+
socket=options.socket,
773+
config=options.config
763774
)
764775
except Exception:
765776
pass # Something ain't right. Try the interactive entry method...
@@ -895,6 +906,7 @@ def main():
895906
identities=identities,
896907
additional_args=options.additional_args,
897908
socket=options.socket,
909+
config=options.config,
898910
debug=debug
899911
)
900912
elif protocol == 'telnet':

0 commit comments

Comments
 (0)