SSH client is a program for logging into a remote machine and for executing commands on a remote machine. By default in Linux/UNIX if particular command/shell script is executed, it return two type of values which is used to see whether command or shell script executed is successful or not. This value is know as Exit Status of shell command or script.
The session terminates when the command or shell on the remote machine exits and all X11 and TCP/IP connections have been closed. The exit status of the remote program is returned as the exit status of ssh. You can use bash shell $? Variable to print exit status of shell. For example:
user@localhost: $ ssh email@example.com
firstname.lastname@example.org: $ exit
user@localhost: $ echo $?
- ssh exits with the exit status of the remote command which can be find with echo $? command.
- Or value 255 is return, if an error occurred while processing request via ssh session