Running Remote Applications through SSH

پښتو :: پښتانه :: پښتونخواه :: پښتونوالی

Running Remote Applications through SSH, Omar Usman
Published in Khyber.ORG on Monday, January 18 2010 (http://www.khyber.org)


Latest Updates

Frequent Keywords

history marwat afghanistan pashto india peshawar geneology afghan culture british afghans khyber kabul folklore baloch


Running Remote Applications through SSH

Omar Usman

Publishing Date: Monday, January 18 2010

This write-up will show how to setup a somewhat mini-remote desktop on your computers. It may be useful for those people who are behind firewalls or http proxies in their workplaces and want to connect to their home machines. The normal way to do this would be through VNC (for linux) and remote desktop (for windows) but obviously these may be blocked in your workplace. The example is based on a Gentoo machine (acting as a server) and any other linux distribution as client.

Things to do on the server

I am running Gentoo on the server. To install SSH, run:
emerge openssh
Once installed, we will edit the configuration file for both the server and the client.
nano /etc/ssh/sshd_config
Add the following lines to the end of the config file:
X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes
Then edit the configuration file for the client:
nano /etc/ssh/ssh_config
Add the following lines to the end of the config file:
ForwardX11 yes
Once done, start the SSH daemon:
/etc/init.d/sshd start
(Note if already started, you need to restart it so that the config changes are reflected in the service: /etc/init.d/sshd restart)You may install the following which we will also use for testing purpose:
emerge xclock xterm xcalc xlogo xedit xload
The next thing you need to know is what is your external IP. You can find this simply by going to whatismyip.com. You may also set up an account for yourself on dyndns.org so that you don't have to find out your server ip address everytime.

Things to do on the Client

I am running Fedora Core 12 as a client, but pretty much any linux distribution will do the job as long as you have ssh on it. To connect, give the following on your terminal
ssh [your ip address] -X
After some security prompts (key and password), you should be able to see your remote shell. You can do pretty much everything over here. To check graphical applications, enter the following:
xclock
After a while (depending on your net speed), you should be able to see a clock display on your desktop. Congratulations. You can also try the rest of the tools you installed
xterm
xcalc
xedit
Let's test something else which is complicated. If you have firefox on your remote machine, fire up firefox
firefox
After a brief while, you will see Mozilla firefox just like the remaining GUI tools. Unfortunately, the environment you will see here will still be your local client environment. (For example, if we give an address 192.168.*.* of any local computer on the remote network, it will fail to show up). To work around this, we are going to try something different. Press CTRL+ALT+F2 on your client and you will be forwarded to a non-X login prompt. Login with your username and password and enter the following at the shell:
xinit -- :1 vt8
This will create a new graphical shell on F8. The previous graphical shell always runs on F7. To see what we have got, press CTRL+ALT+F8 and you should be able to see an xterm window. You can shift back and forth between both shells (CTRL+SHIFT+F7 and CTRL+SHIFT+F8). Fire up ssh from the new graphical shell in the same manner:
ssh [your ip address] -X
Once you are connected, you may need to load up a window manager to make things easy for you. Type:
mwm &
on the remote shell. This is the motiff window manager and you have run it as a background process. If you have a good internet connection you may also try "gnome-session" or any other desktop environment instead of "mwm". Now enter:
firefox &
Once firefox loads, you can access your local computers just as if you were on the remote site. A way of putting this to good use is configuring your router (which are typically loaded on 192.168.1.1 from the browser). Of course you may configure remote access on your router as well but that is a different thing.

Note for Proxy's and Firewalls

SSH works by default on port 22. If this port is blocked, you may try to install and configure corkscrew on your system. Corkscrew will help in tunnelling SSH through the the http proxy. If it still fails, there is a very nice work around. You may setup port forwarding on your remote router such that any communication from your client IP address using port 80 is going to be forwarded to the local port 22. The only drawback of this will be that you may not be able to connect to any web services from that very ip address.

Comments

Comments powered by Disqus

Running Remote Applications through SSH, Omar Usman
Published in Khyber.ORG on Monday, January 18 2010 (http://www.khyber.org)