hag*_*ope 4 html javascript url ssh terminal
我想创建一个URL链接,以启动终端(从网页或浏览器,例如chrome或safari)和ssh到一个盒子,并启动远程命令(例如ls
),在终端中看起来像:
ssh user@1.2.3.4 'ls'
我试过了:
<a href='ssh://user@1.2.3.4 "ls"'>SSH with ls</a>
但这无能为力。这有效(没有任何命令):
<a href='ssh://user@1.2.3.4'>SSH</a>
HTML可能吗?我还将接受使用Javascript的答案。
我查看了多个来源并尝试了不同的组合,并得出以下理解
Terminal.app
处理SSH URL,并且没有任何文档支持该命令使用iTerm来做
您创建一个新的配置文件并在同一配置中启用SSH URL处理程序
因此在示例页面下使用
<html>
<body>
<a href="ssh://vagrant@vm/ls -alh">ls -alh</a>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
在我的iTerm
SSH配置文件中的以下命令
/usr/bin/ssh $$USER$$@$$HOST$$ $(echo $$PATH$$ | tr -d '/')
Run Code Online (Sandbox Code Playgroud)
结果是
当然,您想运行python脚本或其他内容,并将这些值传递给它,并让其执行其他功能。但这说明了如何实现这样的设置
关键参考
https://unix.stackexchange.com/questions/75668/why-doesnt-the-ssh-command-follow-rfc-on-uri
https://groups.google.com/forum/#!topic/iterm2-discuss/r0Rk_WZaGWk
http://www.rubicode.com/Software/Bundles.html#RCDefaultApp
https://superuser.com/questions/379342/setting-iterm2-as-the-default-terminal-osx-lion