I am using Debian or Windows with Putty to connect to a remote Debian machine via SSH. The remote machine (Debian) behaves differently from the other SSH servers I know so far.

Whenever I run a command in the SSH console that failes, the connection is closed and the SSH client exits.

An example:

  1. I log into the remote machine.
  2. I execute cd /not-exixting-directory.
  3. The SSH client reports the server has closed the connection.

What may be the reason for this behavior and what can I do about it?

  • 1
    What is your remote shell? Putty likely has very little to do with the situation, BTW.
    – Jeff Schaller
    Sep 26, 2018 at 10:42
  • will it fail for any command like echo "asdf" or cd /
    – prosti
    Sep 26, 2018 at 11:21

1 Answer 1


If your remote shell is bash (or Bourne-like), you likely have the errexit option turned on. The option instructs the shell to exit immediately if a "simple" command (such as cd) returns with an error.

Confirm, after you log in, by running:

echo "$-" | grep e

If the option is turned on, you'll see a line of text containing an e. If not, no text will be returned.

Alternatively, run:

set -o|grep errexit

If the option is turned on, you'll see:

errexit         on

If not, you'll see:

errexit         off

To turn the option off, run:

set +o errexit


set +e

For more information about errexit, see Shell Command Lanugage - set

  • Thanks a lot, the problem was a script containing set -e. Sep 26, 2018 at 11:46
  • 1
    A more-painful workaround would be to append || true to any command that might fail.
    – Jeff Schaller
    Sep 26, 2018 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.