Why would one have to exit twice when leaving an ssh bash connection? [closed]
Clash Royale CLAN TAG#URR8PPP
up vote
0
down vote
favorite
When connected through SSH, a machine requires that I exit twice before returning to the local computer's shell; is there a reason why this happens, it doesn't seem like it should work that way.
bash ubuntu ssh
closed as unclear what you're asking by Ipor Sircer, Romeo Ninov, maulinglawns, Thomas, Jeff Schaller Sep 17 at 11:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
 |Â
show 3 more comments
up vote
0
down vote
favorite
When connected through SSH, a machine requires that I exit twice before returning to the local computer's shell; is there a reason why this happens, it doesn't seem like it should work that way.
bash ubuntu ssh
closed as unclear what you're asking by Ipor Sircer, Romeo Ninov, maulinglawns, Thomas, Jeff Schaller Sep 17 at 11:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
I have never seen/experienced this myself. Could you possibly include more information about the server in your question?
â maulinglawns
Sep 17 at 5:46
Ubuntu 16.04 LTS on a MacPro Early 2008...that's about it...
â leeand00
Sep 17 at 5:54
3
You would have to exit twice to exit the SSH session if you have started an interactive shell on top of the one you got viassh
(started, either manually or via one of your shell's startup files). You don't mention anything about your shells's configuration.
â Kusalananda
Sep 17 at 5:56
2
I often have to "exit" twice when I log into my vps, but that's because I login using a script that automatically connects me to a screen I have running there, so I first have to detach from that screen and then exit the SSH session.
â Henrik
Sep 17 at 6:09
@Henrik Unless you need to do other things in your script oncescreen
has terminated, you may useexec screen
to replace the script process withscreen
.
â Kusalananda
Sep 17 at 8:00
 |Â
show 3 more comments
up vote
0
down vote
favorite
up vote
0
down vote
favorite
When connected through SSH, a machine requires that I exit twice before returning to the local computer's shell; is there a reason why this happens, it doesn't seem like it should work that way.
bash ubuntu ssh
When connected through SSH, a machine requires that I exit twice before returning to the local computer's shell; is there a reason why this happens, it doesn't seem like it should work that way.
bash ubuntu ssh
bash ubuntu ssh
asked Sep 17 at 5:42
leeand00
1,31232138
1,31232138
closed as unclear what you're asking by Ipor Sircer, Romeo Ninov, maulinglawns, Thomas, Jeff Schaller Sep 17 at 11:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as unclear what you're asking by Ipor Sircer, Romeo Ninov, maulinglawns, Thomas, Jeff Schaller Sep 17 at 11:04
Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, itâÂÂs hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.
I have never seen/experienced this myself. Could you possibly include more information about the server in your question?
â maulinglawns
Sep 17 at 5:46
Ubuntu 16.04 LTS on a MacPro Early 2008...that's about it...
â leeand00
Sep 17 at 5:54
3
You would have to exit twice to exit the SSH session if you have started an interactive shell on top of the one you got viassh
(started, either manually or via one of your shell's startup files). You don't mention anything about your shells's configuration.
â Kusalananda
Sep 17 at 5:56
2
I often have to "exit" twice when I log into my vps, but that's because I login using a script that automatically connects me to a screen I have running there, so I first have to detach from that screen and then exit the SSH session.
â Henrik
Sep 17 at 6:09
@Henrik Unless you need to do other things in your script oncescreen
has terminated, you may useexec screen
to replace the script process withscreen
.
â Kusalananda
Sep 17 at 8:00
 |Â
show 3 more comments
I have never seen/experienced this myself. Could you possibly include more information about the server in your question?
â maulinglawns
Sep 17 at 5:46
Ubuntu 16.04 LTS on a MacPro Early 2008...that's about it...
â leeand00
Sep 17 at 5:54
3
You would have to exit twice to exit the SSH session if you have started an interactive shell on top of the one you got viassh
(started, either manually or via one of your shell's startup files). You don't mention anything about your shells's configuration.
â Kusalananda
Sep 17 at 5:56
2
I often have to "exit" twice when I log into my vps, but that's because I login using a script that automatically connects me to a screen I have running there, so I first have to detach from that screen and then exit the SSH session.
â Henrik
Sep 17 at 6:09
@Henrik Unless you need to do other things in your script oncescreen
has terminated, you may useexec screen
to replace the script process withscreen
.
â Kusalananda
Sep 17 at 8:00
I have never seen/experienced this myself. Could you possibly include more information about the server in your question?
â maulinglawns
Sep 17 at 5:46
I have never seen/experienced this myself. Could you possibly include more information about the server in your question?
â maulinglawns
Sep 17 at 5:46
Ubuntu 16.04 LTS on a MacPro Early 2008...that's about it...
â leeand00
Sep 17 at 5:54
Ubuntu 16.04 LTS on a MacPro Early 2008...that's about it...
â leeand00
Sep 17 at 5:54
3
3
You would have to exit twice to exit the SSH session if you have started an interactive shell on top of the one you got via
ssh
(started, either manually or via one of your shell's startup files). You don't mention anything about your shells's configuration.â Kusalananda
Sep 17 at 5:56
You would have to exit twice to exit the SSH session if you have started an interactive shell on top of the one you got via
ssh
(started, either manually or via one of your shell's startup files). You don't mention anything about your shells's configuration.â Kusalananda
Sep 17 at 5:56
2
2
I often have to "exit" twice when I log into my vps, but that's because I login using a script that automatically connects me to a screen I have running there, so I first have to detach from that screen and then exit the SSH session.
â Henrik
Sep 17 at 6:09
I often have to "exit" twice when I log into my vps, but that's because I login using a script that automatically connects me to a screen I have running there, so I first have to detach from that screen and then exit the SSH session.
â Henrik
Sep 17 at 6:09
@Henrik Unless you need to do other things in your script once
screen
has terminated, you may use exec screen
to replace the script process with screen
.â Kusalananda
Sep 17 at 8:00
@Henrik Unless you need to do other things in your script once
screen
has terminated, you may use exec screen
to replace the script process with screen
.â Kusalananda
Sep 17 at 8:00
 |Â
show 3 more comments
1 Answer
1
active
oldest
votes
up vote
2
down vote
This would happen if you started a new interactive shell on top of the one started by ssh
. A new shell would be started if you, for example, executed screen
or tmux
(or bash
or some other shell for that matter) from you shell's startup files (e.g. ~/.bash_profile
for bash
), or from some system wide shell startup file in /etc
.
Starting screen
or tmux
from there would temporarily "suspend" the startup of the initial shell while the other process is running. Once you exit screen
or tmux
, the initial shell session would give you a new prompt that you would have to exit from separately.
To work around this, instead of just using screen
or tmux
, use exec screen
or exec tmux
. This would replace the current shell with the appropriate process.
If you do it this way, make sure that no further setup is needed after the call to exec
as this call will never return the control to the startup script (unless an error occurs in executing exec
).
This is an example from my own ~/.profile
file (I don't use bash
) for starting tmux
when I log in:
if [ -z "$TMUX" ] && [ -z "$DISPLAY" ]; then
if tmux has-session; then
exec tmux attach-session
else
exec tmux
fi
fi
This would replace the current shell with tmux
if the shell session was not already running in a tmux
session (TMUX
would be set if it was), and also if we're not in a graphical environment (DISPLAY
would be set if we were). If there exists a tmux
session, this session is attached, otherwise a new one is started.
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
This would happen if you started a new interactive shell on top of the one started by ssh
. A new shell would be started if you, for example, executed screen
or tmux
(or bash
or some other shell for that matter) from you shell's startup files (e.g. ~/.bash_profile
for bash
), or from some system wide shell startup file in /etc
.
Starting screen
or tmux
from there would temporarily "suspend" the startup of the initial shell while the other process is running. Once you exit screen
or tmux
, the initial shell session would give you a new prompt that you would have to exit from separately.
To work around this, instead of just using screen
or tmux
, use exec screen
or exec tmux
. This would replace the current shell with the appropriate process.
If you do it this way, make sure that no further setup is needed after the call to exec
as this call will never return the control to the startup script (unless an error occurs in executing exec
).
This is an example from my own ~/.profile
file (I don't use bash
) for starting tmux
when I log in:
if [ -z "$TMUX" ] && [ -z "$DISPLAY" ]; then
if tmux has-session; then
exec tmux attach-session
else
exec tmux
fi
fi
This would replace the current shell with tmux
if the shell session was not already running in a tmux
session (TMUX
would be set if it was), and also if we're not in a graphical environment (DISPLAY
would be set if we were). If there exists a tmux
session, this session is attached, otherwise a new one is started.
add a comment |Â
up vote
2
down vote
This would happen if you started a new interactive shell on top of the one started by ssh
. A new shell would be started if you, for example, executed screen
or tmux
(or bash
or some other shell for that matter) from you shell's startup files (e.g. ~/.bash_profile
for bash
), or from some system wide shell startup file in /etc
.
Starting screen
or tmux
from there would temporarily "suspend" the startup of the initial shell while the other process is running. Once you exit screen
or tmux
, the initial shell session would give you a new prompt that you would have to exit from separately.
To work around this, instead of just using screen
or tmux
, use exec screen
or exec tmux
. This would replace the current shell with the appropriate process.
If you do it this way, make sure that no further setup is needed after the call to exec
as this call will never return the control to the startup script (unless an error occurs in executing exec
).
This is an example from my own ~/.profile
file (I don't use bash
) for starting tmux
when I log in:
if [ -z "$TMUX" ] && [ -z "$DISPLAY" ]; then
if tmux has-session; then
exec tmux attach-session
else
exec tmux
fi
fi
This would replace the current shell with tmux
if the shell session was not already running in a tmux
session (TMUX
would be set if it was), and also if we're not in a graphical environment (DISPLAY
would be set if we were). If there exists a tmux
session, this session is attached, otherwise a new one is started.
add a comment |Â
up vote
2
down vote
up vote
2
down vote
This would happen if you started a new interactive shell on top of the one started by ssh
. A new shell would be started if you, for example, executed screen
or tmux
(or bash
or some other shell for that matter) from you shell's startup files (e.g. ~/.bash_profile
for bash
), or from some system wide shell startup file in /etc
.
Starting screen
or tmux
from there would temporarily "suspend" the startup of the initial shell while the other process is running. Once you exit screen
or tmux
, the initial shell session would give you a new prompt that you would have to exit from separately.
To work around this, instead of just using screen
or tmux
, use exec screen
or exec tmux
. This would replace the current shell with the appropriate process.
If you do it this way, make sure that no further setup is needed after the call to exec
as this call will never return the control to the startup script (unless an error occurs in executing exec
).
This is an example from my own ~/.profile
file (I don't use bash
) for starting tmux
when I log in:
if [ -z "$TMUX" ] && [ -z "$DISPLAY" ]; then
if tmux has-session; then
exec tmux attach-session
else
exec tmux
fi
fi
This would replace the current shell with tmux
if the shell session was not already running in a tmux
session (TMUX
would be set if it was), and also if we're not in a graphical environment (DISPLAY
would be set if we were). If there exists a tmux
session, this session is attached, otherwise a new one is started.
This would happen if you started a new interactive shell on top of the one started by ssh
. A new shell would be started if you, for example, executed screen
or tmux
(or bash
or some other shell for that matter) from you shell's startup files (e.g. ~/.bash_profile
for bash
), or from some system wide shell startup file in /etc
.
Starting screen
or tmux
from there would temporarily "suspend" the startup of the initial shell while the other process is running. Once you exit screen
or tmux
, the initial shell session would give you a new prompt that you would have to exit from separately.
To work around this, instead of just using screen
or tmux
, use exec screen
or exec tmux
. This would replace the current shell with the appropriate process.
If you do it this way, make sure that no further setup is needed after the call to exec
as this call will never return the control to the startup script (unless an error occurs in executing exec
).
This is an example from my own ~/.profile
file (I don't use bash
) for starting tmux
when I log in:
if [ -z "$TMUX" ] && [ -z "$DISPLAY" ]; then
if tmux has-session; then
exec tmux attach-session
else
exec tmux
fi
fi
This would replace the current shell with tmux
if the shell session was not already running in a tmux
session (TMUX
would be set if it was), and also if we're not in a graphical environment (DISPLAY
would be set if we were). If there exists a tmux
session, this session is attached, otherwise a new one is started.
edited Sep 17 at 12:28
answered Sep 17 at 8:06
Kusalananda
108k14209332
108k14209332
add a comment |Â
add a comment |Â
I have never seen/experienced this myself. Could you possibly include more information about the server in your question?
â maulinglawns
Sep 17 at 5:46
Ubuntu 16.04 LTS on a MacPro Early 2008...that's about it...
â leeand00
Sep 17 at 5:54
3
You would have to exit twice to exit the SSH session if you have started an interactive shell on top of the one you got via
ssh
(started, either manually or via one of your shell's startup files). You don't mention anything about your shells's configuration.â Kusalananda
Sep 17 at 5:56
2
I often have to "exit" twice when I log into my vps, but that's because I login using a script that automatically connects me to a screen I have running there, so I first have to detach from that screen and then exit the SSH session.
â Henrik
Sep 17 at 6:09
@Henrik Unless you need to do other things in your script once
screen
has terminated, you may useexec screen
to replace the script process withscreen
.â Kusalananda
Sep 17 at 8:00