|
|
10.6 Shell Script and AppleScript (SSH tunnel for VNC)
This works from the Bash shell:
ssh username@example.com -fL6900:127.0.0.1:5900 -o ExitOnForwardFailure=yes sleep 45 && killall ssh-agent; open -W vnc://screen.example.com:6900Where "username" should be replaced by a username on the remote machine, and "example.com" is the remote’s domain name or IP address. "screen.example.com" can be either 127.0.0.1, or a pseudo domain name you've defined in your /etc/hosts file (which makes it easier for humans to read). The choice of internal port 6900 was arbitrary; any unused internal port may be used. The optional "killall ssh-agent;" is used to remove an ssh keychain helper (which is sometimes launched when the tunnel is established). This ssh tunnel collapses when you close the Screen Sharing app (provided the tunnel has been open longer than the number of seconds specified in the sleep parameter). This all can be easily wrapped inside an AppleScript and made conveniently available via the AppleScript Menulet: do shell script "/usr/bin/ssh username@example.com -fL6900:127.0.0.1:5900 -o ExitOnForwardFailure=yes sleep 45 && killall ssh-agent; open -W vnc://screen.example.com:6900"This was tested under Snow Leopard. Use it in good health! Edited on Apr 06, '11 03:03:11PM by Rainy Day
Deleted comment
Deleted. Edited on Apr 06, '11 03:04:48PM by Rainy Day
Targeting a third machine
Note: If you wish to establish the tunnel to one machine on a remote LAN, but target another machine on that same LAN for screen sharing, then replace 127.0.0.1 in the ssh command with the third (target) machine's IP address. For example, if the third machine's s IP address is 192.168.0.32, the command would look something like this:
do shell script "/usr/bin/ssh username@example.com -fL6900:192.168.0.32:5900 -o ExitOnForwardFailure=yes sleep 45 && killall ssh-agent; open -W vnc://screen.example.com:6900"This was tested under Mountain Lion. |
SearchFrom our Sponsor...Latest Mountain Lion HintsWhat's New:HintsNo new hintsComments last 2 daysNo new commentsLinks last 2 weeksNo recent new linksWhat's New in the Forums?
Hints by TopicNews from Macworld
From Our Sponsors |
|
Copyright © 2014 IDG Consumer & SMB (Privacy Policy) Contact Us All trademarks and copyrights on this page are owned by their respective owners. |
Visit other IDG sites: |
|
|
|
Created this page in 0.09 seconds |
|