Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Sunday, 9 December 2012

How to emulate a remote Linux machine on Mac using X11 port forwarding in ssh ?

Remote Linux server/machine can be accessed from Mac using X11 port forwarding feature in ssh.
X11, also known as X window system, is a combination of server and client programs which can be used to emulate desktop environment of remote Unix like machine on a local machine. The server program of X window system runs on local machine and the client program runs on remote machine.
The best feature of X11 window system is that it is separated into client and server program, which makes it suitable to use both the programs either on same machine or on different machines. For ex, when you are using a Linux desktop with GUI, both client and server programs are running on the same machine and when you access your remote unix like machine from local machine then the server program of X window system runs on local machine and the client program runs on remote machine.
Separation of client and server programs makes X window system really fast over networked connections as most of the drawing work is handled on the local machine.
X window system can be really complex to use over networked connection as server is on the local machine, which makes it difficult for the client, running at remote machine, to see the server.
ssh provides a feature to handle this complexity, which is known as X11 port forwarding.
X11 port forwarding feature of ssh makes a secure tunnel between client and server programs of X window system, so that they can communicate .
Now let's see how to use this feature of ssh to connect to a remote Linux machine from a Mac.
You need to have an X11 server program on your mac to connect to the remote Linux machine.
X11 app comes default with the Operating system for Snow Leopard users, but it has to be downloaded and installed explicitly on Mountain Lion.
Mountain Lion users can download X11 app from here.
Once app is installed, you will have to perform some configuration changes in ssh server running on remote Linux machine.

Add the following lines to the file /etc/ssh/ssh_config

ForwardAgent yes
ForwardX11 yes
ForwardX11Trusted yes

After this uncomment/add the following line in /etc/ssh/sshd_config file.

X11Forwarding yes

Restart the ssh server on remote machine for changes to take effect.
Now on local machine
Open terminal and execute the following command

ssh -X user@host.com

This will log you in to the remote machine if the keys are set, else, it will ask for password.
After you are logged in
Assuming that the remote machine's desktop environment is GNOME, execute the following 
command.

gnome-session

If everything works perfectly, you will be able to see your remote Linux machine GUI on your Mac.

For more info visit.

Sunday, 16 September 2012

How to mount a Pen Drive manually in Linux?

Most of you must be thinking that why do we need to mount a pen drive or any other external Hard Drive manually. Why cant' we just plug in the drive and let Linux do things for us, i.e. formatting (creating a file system on drive) and then mounting it inside the root file system.
The answer is, we can always let Linux automatically mount the drive for us. Infact, in my version of Linux, as soon as I plug in the drive, it is mounted at /media/Pendrive, supposing that my pendrive name is Pendrive.
But sometimes, we do not want automatic mounting. Infact, we want to mount our external hard drive or pendrive at a specified location for things to work. This is the scenario where we need manual mounting of a drive.
Let's see how to mount a drive manually.
If your drive is mounted automatically on plugging in then dismount the drive from the location on which it is mounted by using the command.
umount /media/Pendrive # supposing pendrive is mounted on /media/Pendrive
umount /dev/sdb1 # supposing the name Linux gave to my device is sdb1
You can also give the device name for dismounting if you know, or you can check it by using the command dmesg
Look for an SCSI device with storage capacity as that of your drive ( name would be like sda1,sda2...., sdb1,sdb2...)
Make the directory where you want to mount the drive. Let's say I want to mount the drive at /Folder
Mount the drive using the following command
mount -t ext2 /dev/sdb1 /Folder
Now the drive is mounted at /Folder. Here, ext2 denotes the file system for the drive.
Again, if you want that that your drive should be automatically mounted at the specified location when the system boots up and should be dismounted when the system shuts down, add the following line in /etc/fstab.
/dev/sdb1 /Folder ext2 defaults 0 0
The file systems in /etc/fstab are automatically mounted during system start up and dismounted during system shutdown.
You can always mount all the file systems in fstab using mount -a

For more info visit