mirror of https://github.com/openspug/spug
U api update
parent
818f5265d2
commit
90ffa5e062
|
@ -66,11 +66,11 @@ def valid_ssh(hostname, port, username, password):
|
||||||
AppSetting.set('public_key', public_key, 'ssh public key')
|
AppSetting.set('public_key', public_key, 'ssh public key')
|
||||||
if password:
|
if password:
|
||||||
cli = SSH(hostname, port, username, password=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 && \
|
echo %r >> ~/.ssh/authorized_keys && \
|
||||||
chmod 600 ~/.ssh/authorized_keys' % public_key)
|
chmod 600 ~/.ssh/authorized_keys' % public_key)
|
||||||
if code != 0:
|
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:
|
else:
|
||||||
cli = SSH(hostname, port, username, private_key)
|
cli = SSH(hostname, port, username, private_key)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue