-1

I am running a local shell script on the remote Linux system using the following syntax:

ssh -o PubKeyAuthentication=yes -o PreferredAuthentications=publickey username@servername 'bash -s' < localscript.sh

I have not included any exit commands at the end of my script, however when the script is finished executing the ssh connection with the server seems to automatically close. My question is; do I need to include any exit instructions in my script to ensure that sessions are terminated cleanly on the server side?

Many thanks in advance

gr8odinsraven
  • 143
  • 1
  • 1
  • 6

2 Answers2

1

No, Bash terminates when the script ends. The exit code of the last command becomes the exit code of Bash.

tripleee
  • 175,061
  • 34
  • 275
  • 318
0

You don't. The last information the shell encounters is the end-of-file of 'localscript.sh'. This will lead to the termination of all bash and ssh processes.

blafasel
  • 1,091
  • 14
  • 25