Skip to content

Commit

Permalink
cf-remote connect: Handled errors from ssh
Browse files Browse the repository at this point in the history
Signed-off-by: Ole Herman Schumacher Elgesem <ole.elgesem@northern.tech>
  • Loading branch information
olehermanse committed Jan 29, 2025
1 parent 6cd65af commit 0ebebb6
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions cf_remote/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,13 +935,18 @@ def agent(hosts, bootstrap=None):


def connect_cmd(hosts):

assert hosts and len(hosts)
assert hosts and len(hosts) >= 1 # Ensured by argument parser

if len(hosts) > 1:
user_error("You can only connect to one host at a time")

print("Opening a SSH command shell...")
subprocess.run(["ssh", hosts[0]])

return 0
r = subprocess.run(["ssh", hosts[0]])
if r.returncode == 0:
return 0
if r.returncode < 0:
log.error("The ssh command failed with signal " + str(abs(r.returncode)))
return abs(r.returncode)
assert r.returncode > 0
log.error("The ssh command exited with error code " + str(r.returncode))
return r.returncode

0 comments on commit 0ebebb6

Please sign in to comment.