SSH “一条指令“ 连接多个设备
本文前言虽然在《SSH 远程免密登录教程_win11 ssh免密登录-CSDN博客》实现了免密登录当设备较多时无需一条一条执行ssh D0~DN需要执行一条命令就可以完成ssh连接所有设备配置步骤如下确认可以实现SSH 远程免密登录教程_win11 ssh免密登录-CSDN博客中的免密登录新建一个 open_all_ssh.ps1 文件并用记事本打开填入一下内容 (你的需求可能远远不止以下8台设备D0-D7)保存wt new-tab powershell -NoExit -Command ssh.exe D0 ; new-tab powershell -NoExit -Command ssh.exe D1 ; new-tab powershell -NoExit -Command ssh.exe D2 ; new-tab powershell -NoExit -Command ssh.exe D3 ; new-tab powershell -NoExit -Command ssh.exe D4 ; new-tab powershell -NoExit -Command ssh.exe D5 ; new-tab powershell -NoExit -Command ssh.exe D6 ; new-tab powershell -NoExit -Command ssh.exe D7然后在命令行执行# xx为open_all_ssh.ps1文件所在的位置 powershell -ExecutionPolicy Bypass -File xx\open_all_ssh.ps1功能扩展测试可以发现每个窗口显示的是实际的设备名称隐私性有点差。 Windows Terminal 的 new-tab 支持“--title”参数然而 SSH 连接后远程设备会通过终端转义序列覆盖标签页标题还需要加“--suppressApplicationTitle”可以锁定标题不被覆盖。将open_all_ssh.ps1内容修改一下wt new-tab --title D0 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D0 ; new-tab --title D1 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D1 ; new-tab --title D2 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D2 ; new-tab --title D3 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D3 ; new-tab --title D4 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D4 ; new-tab --title D5 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D5 ; new-tab --title D6 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D6 ; new-tab --title D7 --suppressApplicationTitle powershell -NoExit -Command ssh.exe D7现在运行后每个标签页会显示对应的“虚拟”设备代号啦~本文小结工作中如果能化繁为简也着实能 “爽到自己”感谢您的阅读关注点赞。欢迎在评论区交流