Skip to content

Commit

Permalink
Merge pull request #117 from olehermanse/master
Browse files Browse the repository at this point in the history
cf-remote connect: Handled errors from ssh
  • Loading branch information
olehermanse authored Jan 29, 2025
2 parents 84a5234 + dc7ecc6 commit af73dc9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions cf_remote/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -935,13 +935,20 @@ 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:
print("")
log.error("The ssh command failed with signal " + str(abs(r.returncode)))
return abs(r.returncode)
assert r.returncode > 0
print("")
log.error("The ssh command exited with error code " + str(r.returncode))
return r.returncode

0 comments on commit af73dc9

Please sign in to comment.