Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我从ssh -N <somehost> &bash 脚本开始(创建隧道),脚本结束后连接仍然存在,我看到psssh 进程已分离。
ssh -N <somehost> &
ps
我目前正在使用 杀死后台作业,但是有更好的方法吗?kill jobs -p
kill jobs -p
jobs -p
您是否手动结束脚本? 如果是这样: 尝试在脚本中捕获 QUIT 信号(或其他信号)(我认为使用 trap 内置命令)。然后杀死ssh。 否则: 在脚本末尾终止 ssh。