Skip to content

Commit

Permalink
Update ssh_connect.py
Browse files Browse the repository at this point in the history
changes to ssh_config.py to support a global ssh_config for users liftoff#660
liftoff#660
by edwins
  • Loading branch information
ntaken authored Sep 25, 2020
1 parent 654c1f1 commit 37571f7
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions gateone/applications/terminal/plugins/ssh/scripts/ssh_connect.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -751,15 +760,17 @@ 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],
command=options.command,
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...
Expand Down Expand Up @@ -895,6 +906,7 @@ def main():
identities=identities,
additional_args=options.additional_args,
socket=options.socket,
config=options.config,
debug=debug
)
elif protocol == 'telnet':
Expand Down

0 comments on commit 37571f7

Please sign in to comment.