fix when ./keys/user/ didn't exist bug

pull/26/head
liuzheng712 9 years ago
parent 37b91c40b6
commit ee7675f7ae

@ -130,9 +130,10 @@ def gen_ssh_key(username, password='',
生成一个用户ssh密钥对
"""
private_key_file = os.path.join(key_dir, username)
mkdir(private_key_file, username)
if os.path.isfile(private_key_file):
os.unlink(private_key_file)
ret = bash('ssh-keygen -t rsa -f %s -b %s -P "%s"' % (private_key_file, length, password))
ret = bash('echo -e "y\n"|ssh-keygen -t rsa -f %s -b %s -P "%s"' % (private_key_file, length, password))
if authorized_keys:
auth_key_dir = os.path.join(home, username, '.ssh')

Loading…
Cancel
Save