U api update

pull/22/head
vapao 2020-01-07 16:23:24 +08:00
parent 818f5265d2
commit 90ffa5e062
1 changed files with 2 additions and 2 deletions

View File

@ -66,11 +66,11 @@ def valid_ssh(hostname, port, username, password):
AppSetting.set('public_key', public_key, 'ssh public key')
if password:
cli = SSH(hostname, port, username, password=password)
code, stdout, stderr = cli.exec_command('mkdir -p -m 700 ~/.ssh && \
code, out = cli.exec_command('mkdir -p -m 700 ~/.ssh && \
echo %r >> ~/.ssh/authorized_keys && \
chmod 600 ~/.ssh/authorized_keys' % public_key)
if code != 0:
raise Exception('add public key error: ' + ''.join(x for x in stderr))
raise Exception(f'add public key error: {out!r}')
else:
cli = SSH(hostname, port, username, private_key)