How to Disconnect From SSH Session in Linux

If you’re logged into a remote system via SSH and need to disconnect, there are a few different ways to close the SSH session. You can choose from commands, a keyboard shortcut, or escape characters in the case of a hung connection. In this tutorial, you will learn all the ways possible to disconnect from an SSH session in Linux.

Method 1. Most users will naturally use the exit command to disconnect, as this is also the command to close the terminal and is only a few keystrokes.

$ exit

Disconnecting from an SSH terminal in Linux

Method 2. An even faster way to disconnect is with Ctrl + D. This keyboard combo issues the end-of-file command.

Method 3. Another way to disconnect from an SSH session is the logout command. Only recommended if you are SSHing to another Linux system.

$ logout

Method 4. If you need to force your SSH session to close because it’s become frozen or unresponsive, you can type the escape characters ~. to be returned to your host’s terminal and start using it again.

Leave a Comment

Your email address will not be published. Required fields are marked *