def ensure_private_ssh_key():
global PRIVATE_SSH_KEY
if PRIVATE_SSH_KEY:
key_path = os.path.expanduser('~/.ssh')
key_file = os.path.join(key_path, 'id_rsa')
try:
if not os.path.isdir(key_path):
os.mkdir(key_path)
if not os.path.isfile(key_file):
shutil.copyfile(PRIVATE_SSH_KEY, key_file)
os.chmod(key_file, stat.S_IWRITE | stat.S_IREAD)
except (IOError, OSError) as error:
PRIVATE_SSH_KEY = ''
print(error)
else:
return True
return False
# TODO: unify with frontend config
评论列表
文章目录