I'd like to create a url link that launches terminal (from webpage or browser such as chrome or safari) and ssh's to a box and launches remote commands (for example ls
), in terminal it would look like:
ssh [email protected] 'ls'
I've tried:
<a href='ssh://[email protected] "ls"'>SSH with ls</a>
but this does nothing. and this works (without any commands):
<a href='ssh://[email protected]'>SSH</a>
Is this possible in HTML? I'll also accept answers that use Javascript.
I think what you want is simply this. And simply type: browse (your file name) without the parentheses of course. This will run your HTML file in Firefox browser.
I have looked at multiple sources and tried different combinations and come to below understanding
Terminal.app
handles the SSH url and there is no documentation that it supports command Doing it using iTerm
You create a new profile and enable SSH URL handler in the same
So used below sample page
<html>
<body>
<a href="ssh://vagrant@vm/ls -alh">ls -alh</a>
</body>
</html>
And below command in my iTerm
SSH profile
/usr/bin/ssh $$USER$$@$$HOST$$ $(echo $$PATH$$ | tr -d '/')
And the result was
Of course you want to run a python script or something and pass it these values and let it do such things for additional functionalities. But this shows how you could achieve such a setup
Key References
url scheme for ssh: Calling command on remote host
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
https://apple.stackexchange.com/questions/46666/how-to-access-a-clicked-url-in-a-url-handler-application-created-in-automator
https://support.shotgunsoftware.com/hc/en-us/community/posts/209485898-Launching-External-Applications-using-Custom-Protocols-under-OSX
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With