Exit SSH session in OSX Terminal

40

7

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.

miles

Posted 2012-03-23T18:44:20.703

Reputation: 503

Answers

54

You can press Ctrl+D that will exit the terminal.

J Baron

Posted 2012-03-23T18:44:20.703

Reputation: 800

1It should be either exit or logout to reply to the actual question. Closing the terminal ends the session, but it is not the "clean" way to do it – Marius – 2016-10-03T12:19:03.323

I get this message and then cannot type anymore: [Process completed] – miles – 2012-03-23T19:54:38.897

That is because you are in the local shell for your mac and exiting the process would be my guess. Typically you need to provide credentials to log into another server unless you have ssh keys setup. Are you sure that you are connected to the other server? – J Baron – 2012-03-23T20:35:59.113

this will exit whole terminal with ssh, @coffeeRain's answer is the correct one - use exit – OZZIE – 2014-02-10T16:12:57.870

7You can also just type logout – JuJoDi – 2014-02-13T00:37:02.467

26

Try using the exit command in the Terminal.

CoffeeRain

Posted 2012-03-23T18:44:20.703

Reputation: 447

I get this message and then cannot type anymore: [Process completed] – miles – 2012-03-23T19:54:59.460

8If you are inside the SSH session and you type exit, it will leave the SSH session. If you are not inside an SSH session, it will close the terminal process, and then you will have to Command+Q to Quit the Terminal. – paradd0x – 2012-04-01T13:29:34.143

12

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.

JannieT

Posted 2012-03-23T18:44:20.703

Reputation: 981

What I like about this answer is that it is applicable to other *nix OSs. – John Giotta – 2015-05-14T00:19:11.220

3

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.

Chris Page

Posted 2012-03-23T18:44:20.703

Reputation: 2 793