Commit e3d0a21b authored by Ilias Tsitsimpis's avatar Ilias Tsitsimpis
Browse files

snf-deploy: Remove old keys before generating new

When creating new ssh keys if the key already exists,
ssh-keygen prompts the user if he want to overwrite it.
To avoid prompting the user, delete all the old keys,
before generating new ones (the user has
to use the --force option for this to happen).
parent 15433d7a
......@@ -520,6 +520,10 @@ def must_create_keys(force, env):
def do_create_keys(args, env):
d = os.path.join(env.templates, "root/.ssh")
a = os.path.join(d, "authorized_keys")
# Delete old keys
for filename in os.listdir(d):
os.remove(os.path.join(d, filename))
# Generate new keys
for t in ("dsa", "rsa"):
f = os.path.join(d, "id_" + t)
cmd = 'ssh-keygen -q -t {0} -f {1} -N ""'.format(t, f)
......
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