Finish work in a remote shell opened through SSH.
End the shell normally and close the connection.
Which command can be used?
exit or logout normally terminates the login shell, which closes the SSH session while leaving the remote system running.
Detailed explanation
exitCorrect. exit closes the remote shell and normally ends the SSH session.
haltIncorrect. halt stops the remote system.
kill -9 $$Incorrect. Killing the shell forcefully is unnecessary and can skip cleanup.
shutdown nowIncorrect. shutdown stops the remote system rather than only ending the session.
Try it yourself
An example you can run in a temporary verification environment.
help exitExpected result
Bashのexit builtin説明。現在のshellでは実行しないKey points
- exit
- Normal shell termination
- The system remains running
Notes
- Environment: Bash 5.2/OpenSSH 9.x
- Use a disposable VM or test account when validating installation and SSH behavior.
- Exact command output can vary slightly by distribution and OpenSSH version.
Foundation review
Identify the scope
halt and shutdown affect the host, while killing a shell is an unnecessary forced termination.
Check the side effect
Save or hand off any required long-running work before closing the interactive session.