X applications and Socks proxy via SSH
I have often been very thankful of people who blog/share about things they find out on their own, and want to help others find it out quicker, or just to make little known, but awesome, features more visible. So I thought, maybe I should start to write these small posts about stuff i find, or stuff I want others to know about. So here goes the first.
Remote X applications
Have you ever wanted to run an x application from a distant server, but don’t want to bother with installing VNC or installing anything at all? There is this little known feature in the standard OpenSSH client, which will proxy your X display connection. It’s as easy as running this from a terminal window:
ssh -X email@example.com
Now, after you have authenticated, you can start x applications. For example xclock, or kdevelop or other nifty stuff, and it comes right to your local X windows.
Remote connections using SOCKS
When you develop against remote web services, people often restrict your access by your servers IP address. This way only your web server can connect to the web services. But sometimes the only documentation you get from them are the wsdl pages on their server, or maybe they even expect you to have a web-browser on your server to browse the documentation on their web services server. Then you have a problem right? And links/lynx isn’t always web 2.0 enough. Thankfully I recently found this nice Socks feature in OpenSSH. Just connect as follows:
ssh -D 8080 firstname.lastname@example.org
Now when you are logged in, you automatically have a Socks server running at 127.0.0.1:8080. Go to your favourite browser, and go to proxy settings, and enter 127.0.0.1 port 8080 under the “Socks” configuration, and save. Now all your web-browsing is tunneled through your web server, and you can easily open the documentation you wanted.
If you have an application that does not know of Socks proxying, and still want to ‘tunnel’ your data through your remote server, you can of course always use the more known port forwarding functions in OpenSSH (-L, and -R).