【问题标题】:how to run a ssh reverse tunnel in a startup batch file in background?如何在后台启动批处理文件中运行 ssh 反向隧道?
【发布时间】:2020-01-24 18:45:07
【问题描述】:

基本上我想在启动时编写 .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 隧道而不让用户注意到它?

【问题讨论】:

    标签: windows batch-file ssh ssh-tunnel tunnel


    【解决方案1】:

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

    【讨论】:

    • 那行不通,当我设置 /B 有或没有 /MIN 时,它只会生成一个包含我的命令的 CMD,它确实连接回来但不是隐身
    猜你喜欢
    • 2020-01-08
    • 2010-09-22
    • 2012-06-06
    • 2018-07-08
    • 2011-10-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多