Dear All,
This post explains how to setup ssh X11 forwarding. Please note that this post assumes that you have 2 machines running both with some linux installed.
The scenario:
I have 2 laptops - one connected via LAN and the other one via wifi but on the same network.
I have both laptops installed with Deb* based distro.
Need for ssh x11 forwarding:
1. Many a times when you have multiple systems connected via the same network, you may have to exchange files between them. Also there are scenarios where we have one laptop connected to speakers and the songs in some other laptop.
2. There are needs where in we may have to connect remotely to one of these machine to access some files, open them to edit and rest. We shall take up this scenario in one of the other posts pretty soon.
Pre-requisites:
Here there are 2 entities: (which we shall call them as)
1. Server laptop
2. Client laptop.
On both laptops, openssh client and server needs to be installed. Also make sure that xauth package is installed on the server laptop.
The commands to install these (for a fresh install)
sudo apt-get install openssh-client openssh-server xuath(xauth on the server laptop)
X11 forwarding configuration concepts:
On the server laptop:
1. Set a proper display with the command
export DISPLAY=:0
2. In the file /etc/ssh/ssh_config make sure this below entry is present or else un-comment the lines and change a no to yes as below:
ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes
3. In the file /etc/ssh/sshd_config (be careful with the file names) make sure this below entry is present or else un-comment the lines and change a no to yes except for the last line as below:
AllowAgentForwarding yes
AllowTcpForwarding yes
X11Forwarding yes
X11DisplayOffset 10
4. Note down the IP address of this laptop with the command
ifconfig
For this post discussion we shall assume the IP as 192.168.1.8
5. Finally do not forget this step.. After setting the values do restart the ssh service with the below command:
sudo /etc/init.d/ssh restart
On the client laptop:
1. Connect to the server through a terminal/konsole and with the below command(note usage of putty ssh client is a different process altogether)
ssh user@192.168.1.2 -X (note to replace user with your name on the server laptop)
Give proper authentication credentials to login.
2. Once connected, issue the command,
export $DISPLAY
You should see some laptop / machine name with a display offset. (This is usually the hostname in most cases. )
3. If the output in step 2 is nil, then get back to the server and make sure all steps are properly implemented.
4. Finally verify (if not step 3), that X applications can be loaded easily with the commands:
xeyes or xlogo
5. If you get the output of xeyes or xlogo in step 4, you can also try editing an existing file or by creating a new file by the gedit or any other editor.
gedit a.txt
Finally mission accomplished.. Successful ssh x11 forwarding...
Thats it for now... Hope you had a good learning experience through this post.
Hope to write many more posts...
Tc,
Ananth G S
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment