3

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-existing-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?

0

1 Answer 1

6

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

or

set +e

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

1
  • Thanks a lot, the problem was a script containing set -e.
    – Cellcon
    Sep 26, 2018 at 11:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .