Commit eae52feb by Feanil Patel

Be able to turn off strict host checking.

parent f9016a15
"""VPC Tools. """VPC Tools.
Usage: Usage:
vpc-tools.py ssh-config vpc <vpc_id> identity-file <identity_file> user <user> [config-file <config_file>] vpc-tools.py ssh-config vpc <vpc_id> identity-file <identity_file> user <user> [config-file <config_file>] [strict-host-check <strict_host_check>]
vpc-tools.py (-h --help) vpc-tools.py (-h --help)
vpc-tools.py (-v --version) vpc-tools.py (-v --version)
...@@ -16,6 +16,7 @@ from docopt import docopt ...@@ -16,6 +16,7 @@ from docopt import docopt
VERSION="vpc tools 0.1" VERSION="vpc tools 0.1"
DEFAULT_USER="ubuntu" DEFAULT_USER="ubuntu"
DEFAULT_HOST_CHECK="yes"
JUMPBOX_CONFIG = """ JUMPBOX_CONFIG = """
Host {jump_box} Host {jump_box}
...@@ -23,6 +24,7 @@ JUMPBOX_CONFIG = """ ...@@ -23,6 +24,7 @@ JUMPBOX_CONFIG = """
IdentityFile {identity_file} IdentityFile {identity_file}
ForwardAgent yes ForwardAgent yes
User {user} User {user}
StrictHostKeyChecking {strict_host_check}
""" """
HOST_CONFIG = """ HOST_CONFIG = """
...@@ -32,6 +34,7 @@ HOST_CONFIG = """ ...@@ -32,6 +34,7 @@ HOST_CONFIG = """
IdentityFile {identity_file} IdentityFile {identity_file}
ForwardAgent yes ForwardAgent yes
User {user} User {user}
StrictHostKeyChecking {strict_host_check}
""" """
...@@ -48,10 +51,14 @@ def _ssh_config(args): ...@@ -48,10 +51,14 @@ def _ssh_config(args):
user = args.get("<user>") user = args.get("<user>")
vpc_id = args.get("<vpc_id>") vpc_id = args.get("<vpc_id>")
config_file = args.get("<config_file>") config_file = args.get("<config_file>")
strict_host_check = args.get("<strict_host_check>")
if not user: if not user:
user = DEFAULT_USER user = DEFAULT_USER
if not strict_host_check:
strict_host_check = DEFAULT_HOST_CHECK
if config_file: if config_file:
config_file = "-F {}".format(config_file) config_file = "-F {}".format(config_file)
else: else:
...@@ -73,7 +80,8 @@ def _ssh_config(args): ...@@ -73,7 +80,8 @@ def _ssh_config(args):
jump_box=jump_box, jump_box=jump_box,
ip=instance.ip_address, ip=instance.ip_address,
user=user, user=user,
identity_file=identity_file) identity_file=identity_file,
strict_host_check=strict_host_check)
else: else:
print HOST_CONFIG.format( print HOST_CONFIG.format(
...@@ -84,7 +92,8 @@ def _ssh_config(args): ...@@ -84,7 +92,8 @@ def _ssh_config(args):
user=user, user=user,
logical_id=logical_id, logical_id=logical_id,
identity_file=identity_file, identity_file=identity_file,
config_file=config_file) config_file=config_file,
strict_host_check=strict_host_check)
#duplicating for convenience with ansible #duplicating for convenience with ansible
name = friendly.format(vpc_id=vpc_id, name = friendly.format(vpc_id=vpc_id,
...@@ -98,7 +107,8 @@ def _ssh_config(args): ...@@ -98,7 +107,8 @@ def _ssh_config(args):
user=user, user=user,
logical_id=logical_id, logical_id=logical_id,
identity_file=identity_file, identity_file=identity_file,
config_file=config_file) config_file=config_file,
strict_host_check=strict_host_check)
if __name__ == '__main__': if __name__ == '__main__':
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment