Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes to ssh_config.py to support a global ssh_config for users #660

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation doesn't seem to be correct here. Try running flake8 over this file.

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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: The indentation doesn't seem to be correct here. Try running flake8 over this file.

)
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: The indentation doesn't seem to be correct here. Try running flake8 over this file.

)
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,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above: The indentation doesn't seem to be correct here. Try running flake8 over this file.

debug=debug
)
elif protocol == 'telnet':
Expand Down