The answer for us screen / byobu users:
The geocar solution will not work, as the screen will complain that it should be connected to the terminal. (This is likely due to the fact that .ssh / rc processing is processed before the shell starts. See the INPUT PROCESS section from man 8 sshd ).
Robert's solution here is better, but since screen and byobu open his own instance of bash, we need to avoid infinite recursion. So, the convenient version has been edited here:
## RUN BYOBU IF SSH'D ## ## '''''''''''''''''' ## # (but only if this is a login shell) if shopt -q login_shell then if [ -n "$SSH_CONNECTION" ] then byobu exit fi fi
Note that I also added exit after byobu , since IMO, if you use byobu in the first place, you usually don't want to do anything outside of it.
Alois mahdal
source share