From e6b3345421c734c15fa2db0961e4801a58c0aa84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juhani=20Krekel=C3=A4?= Date: Fri, 31 Aug 2018 20:52:55 +0300 Subject: [PATCH] sshwot-export-known-hosts exports ~/.ssh/known_hosts by default --- src/main-export-known-hosts.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main-export-known-hosts.py b/src/main-export-known-hosts.py index 45d7e99..86d3185 100644 --- a/src/main-export-known-hosts.py +++ b/src/main-export-known-hosts.py @@ -1,4 +1,5 @@ import argparse +import os import sys import process_known_hosts @@ -42,8 +43,16 @@ def main(): help = 'write the sshwot file to a given file instead of the stdout' ) - # The required argument + try: + homedir = os.environ['HOME'] + except KeyError: + raise KeyError('$HOME is not set') + + # The input file + # Default to ~/.ssh/known_hosts parser.add_argument('infile', + nargs = '?', + default = homedir + '/.ssh/known_hosts', help = 'a file in .ssh/known_hosts format' )