管理远程服务器时 不可避免的使用while ,但是当在while下执行循环时 ssh会中断 ,用for执行就不会出现这种问题
解决办法有两个
1.用for循环替代 while循环
2. 用while循环时 ,ssh 增加 -n参数
man ssh
-n Redirects stdin from /dev/null (actually, prevents reading from stdin). This must be used when ssh is
run in the background. A common trick is to use this to run X11 programs on a remote machine. For exam-
ple, ssh -n shadows.cs.hut.fi emacs & will start an emacs on shadows.cs.hut.fi, and the X11 connection
will be automatically forwarded over an encrypted channel. The ssh program will be put in the back-
ground. (This does not work if ssh needs to ask for a password or passphrase; see also the -f option.)