When it comes to managing remote systems in Linux, the SSH protocol is the most used method. SSH is popular because it allows a user to securely log in to remote devices, including other Linux systems, firewalls, routers, etc. When you are done with your remote management, you can quit out of the SSH connection.
In this tutorial, you will learn about the commands that can be used to quit an SSH connection in Linux. You will also learn the escape characters to exit from an SSH session, which comes in handy if you encounter a hung system that you have an SSH connection into and need to return to your local terminal.
In this tutorial you will learn:
- How to quit from an SSH connection in Linux
- How to quit out of a hung or frozen SSH connection
|Category||Requirements, Conventions or Software Version Used|
|System||Any Linux distro|
|Other||Privileged access to your Linux system as root or via the
# – requires given linux commands to be executed with root privileges either directly as a root user or by use of
$ – requires given linux commands to be executed as a regular non-privileged user
Linux Command to Quit SSH Session – All Methods
There are numerous Linux commands that can be used to quit an SSH connection. Check out the various methods below:
- The typical way to quit from an SSH connection is by using the
exitcommand. This command will work for disconnecting from Linux systems, as well as a variety of other devices and operating systems. It is the method that most administrators use.
- The second way to quit out of an SSH session is with the
logoutcommand. This will work on Linux systems but may not work for other devices with different operating systems. But usually it will work.
- If you are the kind of user that loves keyboard shortcuts and maximum efficiency, you may like the
Ctrl + Dshortcut, which issues an end of file command. This will instantly quit an SSH session.
DID YOU KNOW?
Hung or frozen SSH session? You can use the
~.characters to quit an SSH session which has become unresponsive. Read more below.
If your SSH connection is frozen, the three methods above may not work for you. In that case, you can type
~.to quit the SSH session and return to your local command line terminal. This works as an escape character for SSH connections.
In this tutorial, we saw how to quit an SSH session on a Linux system. SSH is an essential tool for remote adminitration, so knowing how to logout will be necessary whenever you are ready to quit your connection. The two methods we recommend remembering are
~.escape characters, just in case you get a hung connection.