The choice of internal port 6900 was arbitrary any unused internal port may be used. "" 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). This works from the Bash shell: ssh -fL 6900:127.0.0.1:5900 -o ExitOnForwardFailure=yes sleep 45 & killall ssh-agent open -W vnc:// : 6900Where "username" should be replaced by a username on the remote machine, and "" is the remote’s domain name or IP address. To felix-fi, I also have to pull up the man page to ssh ever time I start thinking about tunnels sorry for any aggravation from mixed up variables four years ago. The version here is secure and done up properly. I first posted a version of this script years ago with an incorrect variable in response to a question from felix-fi (who commented above) on another site about securing afp (just change the ports and the open command). Someone clever and less lazy than me could surely wrap this up in AppleScript for click and go fun if that is you, share and enjoy. The terminal window will wait for you to hit return when you are done with your secure vnc, hitting return kills the tunnel so you do not have it sitting around un-noticed. Svnc you have JollyFastVNC.app in your Applications folder, it will open and you connect to localhost (127.0.0.1) and port 5902 Save with your favorite text editor (I call mine svnc) and chmod u+x to make it executable then, if the file is in your path, you can fire up your secure tunnel by typing: read answer clear kill $TUN echo SSH tunnel closed. echo This will manually close down your SSH tunnel to the remote computer. echo When you finish your VNC session, press the ENTER key in this window. I use this handy shell script to secure my vnc through a tunnel: #!/bin/sh# script to make ssh tunnel connect to vnc host specified in# first argument# W Penn - creation# W Penn - command arguments added converted for vnc# some dude named ward - process management added#LOCAL_PORT=5902 TARGET_HOST=127.0.0.1 TARGET_PORT=5900 TUNNEL_HOST="$1" echo "opening tunnel" ssh -L $LOCAL_PORT:$TARGET_HOST:$TARGET_PORT -f -N $TUNNEL_HOST echo "Local port $LOCAL_PORT used" echo "opening vnc client" open -a /Applications/JollyFastVNC.app/ clear TUN=`lsof -i:$LOCAL_PORT -Fp | head -1| sed s/p//` echo IMPORTANT: Leave this Terminal window open during your VNC session.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |