Home > Hosting > Server

How to use the SSH exit character to switch SSH sessions in Linux

2023-03-17 14:49:50

<p style="text-align: left;">This article mainly explains how Linux uses the SSH exit character to switch SSH sessions. Interested friends may wish to take a look. The method described in this article is simple, quick and practical. Now let the editor take you to learn how to use the SSH exit character to switch SSH sessions in Linux!</p><p style="text-align: left;"><strong>1. Log in to the remote host:</strong></p><p style="text-align: left;">localhost$ ssh 172.16.1.165<br/>[email protected]&#39;s password:<br/>last login: fri mar 26 14:48:08 2010 from euos</p><p style="text-align: left;"><strong>2. Connected to the remote host :</strong></p><p style="text-align: left;">remotehost$</p><p style="text-align: left;"><strong>3. To temporarily return to the local host, enter the exit symbol: &quot;~&quot; combined with &quot;control-z&quot;.</strong></p><p style="text-align: left;">When you enter &quot;~&quot;, you will not see it on the screen immediately, and it will be displayed together after you press Enter.<br/>As follows, enter &quot;~&quot; in the remote host &quot;<br/>remotehost$ ~^z [suspend ssh]<br/>[1]+ stopped ssh 172.16.1.165<br/>localhost$</p><p style="text-align: left;"><strong>4. Now it has returned to the local The host, the ssh remote client session is running in the unix background, you can view it like this: </strong></p><p style="text-align: left;">localhost$ jobs <br/>[1]+ stopped ssh 172.16.1.165</p><p style="text-align: left;"><strong>5. You can switch the ssh session process running in the background to the foreground and return to the remote host again without entering a password</strong></p><p style="text-align: left;">localhost$ fg %1 <br/>ssh 172.16.1.165<br/>remotehost$</p><p><br/></p>


Copyright Description:No reproduction without permission。

Knowledge sharing community for developers。

Let more developers benefit from it。

Help developers share knowledge through the Internet。

Follow us