mirror of
https://github.com/rwinkhart/sshyp.git
synced 2026-09-03 23:57:17 -04:00
Do not connect to server from "sshyp init" menu, as the user may not yet have copied their ssh pubkey to the server
This commit is contained in:
+17
-8
@@ -258,14 +258,23 @@ def dev_id_config(_port, _username_ssh, _ip, _identity, _reconfig=False):
|
|||||||
for _id in _device_id_list:
|
for _id in _device_id_list:
|
||||||
remove(f"{home}/.config/sshyp/devices/{_id}")
|
remove(f"{home}/.config/sshyp/devices/{_id}")
|
||||||
open(f"{home}/.config/sshyp/devices/{_device_id}", 'w')
|
open(f"{home}/.config/sshyp/devices/{_device_id}", 'w')
|
||||||
# test server connection and attempt to register device id - copy_id_check() returns false if successful
|
# test server connection and attempt to register device id - only run if _reconfig is True, since the keyfile
|
||||||
if not copy_id_check(_port, _username_ssh, _ip, _device_id, _identity, sshyp_data):
|
# needs to be registered with the server before a successful connection can be made
|
||||||
# remove old device id from registered pool and whitelist
|
if _reconfig:
|
||||||
run(('ssh', '-o', 'ConnectTimeout=3', '-i', _identity, '-p', _port, f"{_username_ssh}@{_ip}",
|
# copy_id_check() returns false if successful
|
||||||
'python3 -c \'from pathlib import Path; '
|
if not copy_id_check(_port, _username_ssh, _ip, _device_id, _identity, sshyp_data):
|
||||||
f'Path("/home/{_username_ssh}/.config/sshyp/devices/{_device_id_list[0]}").unlink(missing_ok=True); '
|
# remove old device id from registered pool and whitelist
|
||||||
f'Path("/home/{_username_ssh}/.config/sshyp/whitelist/{_device_id_list[0]}").unlink(missing_ok=True)\''),
|
run(('ssh', '-o', 'ConnectTimeout=3', '-i', _identity, '-p', _port, f"{_username_ssh}@{_ip}",
|
||||||
stderr=DEVNULL, stdout=DEVNULL)
|
'python3 -c \'from pathlib import Path; '
|
||||||
|
f'Path("/home/{_username_ssh}/.config/sshyp/devices/{_device_id_list[0]}").unlink(missing_ok=True); '
|
||||||
|
f'Path("/home/{_username_ssh}/.config/sshyp/whitelist/{_device_id_list[0]}")'
|
||||||
|
f'.unlink(missing_ok=True)\''), stderr=DEVNULL, stdout=DEVNULL)
|
||||||
|
else:
|
||||||
|
sshyp_data.set('CLIENT-ONLINE', 'ssh_error', 'true')
|
||||||
|
write_config()
|
||||||
|
curses_radio(['okay'], 'this device will be registered with the server upon the first successful sync\n\n'
|
||||||
|
'you can force this now by running "sshyp sync"\n\nif you have not done so already, '
|
||||||
|
'ensure your ssh pubkey has been appended to the server\'s authorized_keys file!')
|
||||||
|
|
||||||
|
|
||||||
# quick-unlock configuration
|
# quick-unlock configuration
|
||||||
|
|||||||
Reference in New Issue
Block a user