Monday, February 23, 2009

015 通过转移符号在SSH会话之间切换

在你连接到远程主机后,你可能希望回到本机执行一些任务然后再回到远程主机上。在这种情况下你不必断开与远程主机的连接,按照下面的步骤就可以:
1.从本机登录到远程主机
localhost$ ssh -l jsmith remotehost

2.现在你已经连接到远程主机
remotehost$

3.要回到本机的会话中,你需要键入转移符号~并按下Control-Z
你输入~之后必须按下Control-Z并回车才能看到本机的界面,所以在远程主机上你应该在新的一行中输入下面的命令:
remotehost$ ~^Z 
[1]+ Stopped ssh -l jsmith remotehost

localhost$

4.现在你已经返回到了本机会话中而远程主机会话会当作一个UNIX后台任务运行,你可以通过下面的命令验证一下:
localhost$ jobs 
[1]+ Stopped ssh -l jsmith remotehost

5.无需输入密码你就可以直接返回到远程主机上,这个过程只是把后台任务调到前台执行:
localhost$ fg %1 
ssh -l jsmith remotehost

remotehost$

No comments:

Post a Comment