Exit SSH session in OSX Terminal
I connected to a server via SSH in Terminal (OSX), but now anytime I open Terminal, it logs me back in. If I logout, I cannot type anything or do anything.
How do I exit back to the regular terminal so I can run a script on my mac? I realize this is probably a really noob question.
Solution 1:
You can press Ctrl+D that will exit the terminal.
Solution 2:
Try using the exit
command in the Terminal.
Solution 3:
When exit
doesn't work, I often have to use Enter
~. (that is ENTER TILDE PERIOD) to log out of the emote server without killing the terminal window. This dumps me back into my local machine prompt.
Solution 4:
If you’re using Mac OS X 10.7 Lion or later, Terminal automatically restores windows and terminal sessions that were open when you Quit (see “Resume” on the What’s New page for Lion). If you created the SSH session with the Shell > New Remote Connection… command, Terminal will remember and create that connection again when restoring that terminal.
If this is what you’re encountering, just close that terminal window/tab and create a new one.
If new terminals also exhibit this behavior, you likely have a custom command in your preferences. Look at Preferences > Settings > [profile] > Shell > Startup > Run command and see if there’s a command in the text field. If so, remove it.
Also check Preferences > Startup > Shells open with: to see if there’s a custom command being used for the shell.