semaphoreci / cli

Semaphore 2.0 Command Line Interface
Apache License 2.0
25 stars 13 forks source link

Handle SSH Server/Client race conditions; Verbose message if SSH returns permission denied #140

Closed shiroyasha closed 5 years ago

shiroyasha commented 5 years ago

This PR improves two cases:

When the SSH daemon and client have a race condition

Example from support:

CLI closed the session immediately, instead of retrying.

When the exported SSH key has no rights to access the job.

Previously we would simply fail. Now we display a meaningful message.

Examples

✲ ~/code/cli (ssh-connection-test) sem debug job aa63c7dd-49de-4897-bea6-6a8d36ced508
* Creating debug session for job 'aa63c7dd-49de-4897-bea6-6a8d36ced508'
* Setting duration to 60 minutes
* Waiting for debug session to boot up ...
* Waiting for ssh daemon to become ready ....................

[ERROR] SSH connection can't be established; Permission denied (publickey); exit status 255

* Stopping debug session ..
* Session stopped
✲ ~/code/cli (ssh-connection-test) sem debug job aa63c7dd-49de-4897-bea6-6a8d36ced508
* Creating debug session for job 'aa63c7dd-49de-4897-bea6-6a8d36ced508'
* Setting duration to 60 minutes
* Waiting for debug session to boot up .....
* Waiting for ssh daemon to become ready .

Semaphore CI Debug Session.

  - Checkout your code with `checkout`
  - Run your CI commands with `source ~/commands.sh`
  - Leave the session with `exit`

Documentation: https://docs.semaphoreci.com/article/75-debugging-with-ssh-access.

semaphore@semaphore-vm:~$ exit
logout
Connection to 235.204.56.15 closed.

* Stopping debug session ..
* Session stopped