当从本地通过SSH登录到远程主机, 可能需要回到本地执行某些活动, 且在结束后返回远程主机. 在本示例中, 不需要断开远程SSH会话, 操作步骤如下:
1. 从本地登录远程主机:
localhost$ ssh -l jsmith remotehost
2. 现在已连接到远程主机:
remotehost$
3. 临时返回本地, 键入转义符 ~ 和 Control-Z.
当键入~后并不会马上在屏幕上显示, 直到输入 <Control-Z> 和 回车.
remotehost$ ~^Z
[1]+ Stopped ssh -l jsmith remotehost
localhost$
4. 现在返回本地主机, SSH远程主机会话做为一个典型的UNIX进程在后台运行:
localhost$ jobs
[1]+ Stopped ssh -l jsmith remotehost
5. 切换回SSH远程主机会话(不需要再次输入密码).
localhost$ fg %1
ssh -l jsmith remotehost
remotehost$