sshd -i always exiting with exit status 255

Donald Buczek buczek at molgen.mpg.de
Sat May 25 06:17:53 AEST 2024


Hi,

I've created a tool which utilizes sshd to enable users to get an interactive session on a Linux compute cluster. The tool submits a wrapper into the cluster. This wrapper creates the listen socket on a dynamic port number, accepts a connection on that socket and then calls sshd in inetd mode with '-i'. Everything works fine and as intended.

However, there is one nuisance: I've noticed that sshd always terminates with exit status 255 even if the interactive session is closed normally. Because of this I can't just exec() sshd from the wrapper as its last step, but need to fork sshd, wait for it, ignore its exit status and exit the wrapper with exit status 0 to communicate a normal exit to the cluster scheduler. This could cover real and unexpected errors.

I've used gdbserver to attach to the sshd process, so I can tell that the exit status of the main (the "privileged" process?) of sshd originates in mm_request_receive from the EPIPE errno check:

void
mm_request_receive(int sock, struct sshbuf *m)
{
     u_char buf[4], *p = NULL;
     u_int msg_len;
     int r;

     debug3_f("entering");

     if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) {
         if (errno == EPIPE)
             cleanup_exit(255);
         fatal_f("read: %s", strerror(errno));
     }

Questions:

- Is this the expected exit point of `sshd -i` ?
- If so, is there a reason to return a failure exit status?

Thanks!

   Donald

-- 
Donald Buczek
buczek at molgen.mpg.de
Tel: +49 30 8413 1433


More information about the openssh-unix-dev mailing list