繁体   English   中英

如何在后台启动批处理文件中运行 ssh 反向隧道?

[英]how to run a ssh reverse tunnel in a startup batch file in background?

基本上我想在启动时在后台执行反向隧道的 write.bat 文件

所以这些是我在批处理文件中尝试过但没有工作的东西

ssh -fN -o StrictHostKeyChecking=no -R port1:localhost:port2 user@ip 

ssh -f -o StrictHostKeyChecking=no -R port1:localhost:port2 user@ip 


start /min cmd.exe /C "ssh -fN -o StrictHostKeyChecking=no -R port1:localhost:port2 user@ip"   

start /min cmd.exe /C "ssh -f -o StrictHostKeyChecking=no -R port1:localhost:port2 user@ip"   


start /min cmd.exe /C "ssh -o StrictHostKeyChecking=no -R port1:localhost:port2 user@ip"   

当我不包括选项 N 并说 -f 时,它不起作用并且我无法从另一端连接

当我说 -fN 时,奇怪的是(有或没有 /min)一个新的空 cmd shell 产生,即使我手动关闭它,我仍然可以连接。 尝试在超时后杀死 cmd.exe 以自动关闭它,但这没有用

但必须有一种方法,我如何在批处理文件中发送反向 ssh 隧道而不让用户注意到它?

我认为您可以尝试编写一个批处理脚本来在启动时运行该命令。 您可以参考https://ss64.com/nt/start.html了解更多信息。 我在其中找到了一个/B参数,可以解决您的问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM