Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exiting ssh -tt session

I am executing a script on a remote ssh host as follows:

ssh -tt $USER@somehost 'bash -s' < ./myscript.sh

Notice the pseudo tty -tt switch.

My problem is that after the script has finished running the ssh session is not ending. Typing exit doesn't do anything either. How do I make it exit?

like image 588
Alex Avatar asked Jul 24 '26 15:07

Alex


1 Answers

You are missing an exit statement.

I suspect the reason that the exit is necessary is because when you force allocation of a pty, the pty is expecting the input to be a terminal... Reading EOF from a terminal doesn't mean 'there is never, ever any more data to come' the way it does for a pipe / file - it just means that there is 'currently no more input from the user' - hence the hang... it's waiting for further input. 

This input script (myscript.sh) 'hangs':

echo "Hello World..."

This doesn't:

echo "Hello World..."
exit 0
like image 62
Attie Avatar answered Jul 27 '26 06:07

Attie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!