SSH Serial Console
Once connected to a serial console via ssh, how do you disconnect from the session. I've been unable to find anything on disconnecting. I've tried using ctrl+ an nothing seems to work. I thought maybe ctrl+] or ctrl+~ but nothing. Right now the only way I can log out of the serial session is to kill the terminal window or search for the connection using lsof and killing the PID.
Thanks,
Responses
Your question is a bit unclear/lacking in details. Serial devices aren't generally SSH'able - at least not directly - so your disconnect is likely to depend on what's being used to create your IP-to-serial gateway.
Similarly, your termination key-sequence is likely to depend on what SSH client you're using. Absent modifications, aborting an SSH session (if going from a UNIX/Linux shell rather than from a PC tool like PuTTY) is a matter of typing ~..
Ok, that makes a bit more sense. Technically, you're not SSHing to the VM's console - you're SSHing to the VM-host and it's gatewaying for you.
In this scenario, there's actually two connections to account for: the ssh to the VM-host and the VM-host's connection to the VM's virtual console. The ~. method only addresses the connection to the VM-host.
The VM-host's connection to the VM's virtual console is kind of an "always on" proposition. This isn't inherently problematic, but it does mean that someone carelessly leaving root logged in the VM's console gives anyone that has permission to the VM-host's console-gateway service the ability to assume whatever rights are active on the console. You can mitigate this, to a degree, by setting idle-timeouts on the login session.
There's a few ways to achieve this.
- The easiest way is probably to set the TMOUT-environmental in
/etc/profile. That said, if someoneexecs another shell, this environment-setting may have no meaning in the substituted shell and the idle timeout may not take place. - Similarly, you should be able to get the getty service to time-out idle connections for you - probably something on the order of setting
LOGIN_TIMEOUTin the /etc/login.defs. In either case, if someone drops the console connection without having logged out, the idle session will auto-terminate after the set period of time. - There's likely also some PAM mods you can make (I just don't recall them off the top of my head)
Either idle-timeout method should reduce the likelihood of someone SSHing through to the virtual console and finding themselves with a #-prompt waiting for them.
Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.
