这就是我想要做的事情:
#!/bin/bash
# start the tunnel
ssh tunnel@hostA -L 6000:hostB:22 -N
# this is the problem, i need to go next process after tunnel on
# Main proses that i must run under tunnel command
sftp -oPort=6000 user@localhost:/home/you <<GETME
lcd /home/me/temp
get *.tar
bye
GETME
echo " Job Done"
# i hope it can be add
# kill the tunnel after sftp done
现在我使用2个putty来运行sftp到hostB,我想也许可以在一个单独的脚本中完成