Verify SSH hostkey before mounting

Signed-off-by: Joseph Nuthalapati <njoseph@thoughtworks.com>
This commit is contained in:
Joseph Nuthalapati committed 2019-07-03 12:42:41 +05:30
1 parent 7684814a5c
commit 3a6dcbe7a7
8 files changed
+146 -120

No files matched your search

+5 -1
View File
@@ -44,6 +44,9 @@ def parse_arguments():
required=True)
mount.add_argument('--ssh-keyfile', help='Path of private ssh key',
default=None, required=False)
mount.add_argument('--user-known-hosts-file',
help='Path to a custom known_hosts file',
default='/dev/null')
umount = subparsers.add_parser('umount', help='unmount an ssh filesystem')
umount.add_argument('--mountpoint', help='Mountpoint to unmount',
required=True)
@@ -69,7 +72,8 @@ def subcommand_mount(arguments):
remote_path = remote_path.replace('~/', '').replace('~', '')
cmd = [
'sshfs', remote_path, arguments.mountpoint, '-o',
'UserKnownHostsFile=/dev/null', '-o', 'StrictHostKeyChecking=no'
f'UserKnownHostsFile={arguments.user_known_hosts_file}', '-o',
'StrictHostKeyChecking=yes'
]
if arguments.ssh_keyfile:
cmd += ['-o', 'IdentityFile=' + arguments.ssh_keyfile]