I closed the terminal while still being logged in to a remote server during an SSH session (I didn't
exit before closing the terminal).
Could this damage the server? What consequences could there possibly be?
Server Fault is a question and answer site for system and network administrators. It only takes a minute to sign up.Sign up to join this community
It won't damage anything just so long as you weren't running something that was making changes to the system (updates, fsck, etc).
If it was just an idle shell session nothing will be harmed.
If you were at the shell and there were no background child processes still attached to the shell there should be no problem.
It won't hurt the server in the least. It's the same as closing a terminal window in OS X or Linux without typing exit. The shell detects the disconnect of the pipe and exits on it's own. This is actually an acceptable way to close a shell. Many other programs also allow this, for instance "Top" and it's variants.
However, remember, closing ssh is basically ending your session, so if a program can't be interrupted without being bad for the server, it is not safe to do. For instance, if you can't safely stop the operation with CTRL-C, then you can't quit.
Also, there are programs that don't properly quit on parent death or pipe disconnect, leaving stranded processes. In this case, you simply need to log back in and kill them manually. Generally it is considered bad practice to disconnect like this, because it is hard to reattach to such a program and interact with it again. Instead, you need to find a way to either detach the program, or daemonize it. Screen is the traditional way to do this, but there are a lot of other choices now, many of which can enhance your terminal, so choose the one you like.