windows - 如何在后台启动批处理文件中运行 ssh 反向隧道?
问题描述
基本上我想在启动时写.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参数,可以解决您的问题。
推荐阅读
- jquery - Wordpress 管理面板中的 jQuery 问题
- list - 根据另一列创建具有多个列的唯一名称的列表?
- javascript - 使用从 Alphavantage 返回的 axios 对象更新 reactjs 状态
- c# - 为什么这个 C# 脚本会导致在 Unity 中循环的游戏对象之间出现延迟峰值?
- android - Android Oreo+:AppWidget 点击不调用 JobIntentService.onHandleWork()
- javascript - 函数在调用时正常运行,但总是返回 undefined
- python - 无法从 gevent 导入 wsgi
- android - BoxStore 中的最大盒子数
- reactjs - 在通用 React 应用程序上存储 JWT 令牌
- ios - 如何在不同的故事板中对导航堆栈中的某些视图控制器执行推送 segue?