Handle SSH connection errors instead of crashing

An unknown hostname, a refused connection or an unreachable server
raise OSError (socket.gaierror, NoValidConnectionsError), which
paramiko.SSHException doesn't cover, so the program crashed with a
traceback. Log the error and exit with code 5 instead.
This commit is contained in:
Fuxino
2026-10-08 20:14:39 +02:00
parent 3113e182c7
commit 7091118663
+7
View File
@@ -177,7 +177,14 @@ class Backup:
self._remote = True
if self._remote:
try:
self._ssh = self._ssh_connect(homedir)
except OSError as e:
# Unknown hostname, connection refused, unreachable host or timeout
logger.critical('Can\'t connect to the server %s', self.ssh_host)
logger.critical(e)
return 5
if self._ssh is None:
return 5