Month: January 2007

How to mount remote ssh filesystem by using sshfs

How to mount remote ssh filesystem by using sshfs

Introduction –

SSH (Secure Shell) is mostly used to login to remote shell (Linux/Unix machine). SSH is protocol to transfer files securely like FTP, but more secure. Transferring files to an from an ssh account can be done using the scp command. What if you could mount a remote folder that you can access using ssh on your local computer? What if you could access files on an ssh account just like they were local files on your pc? Well now you can! mount a folder in an ssh account, edit the files locally and save the files, that’s it! The file will be saved on remote ssh server.

sshfs is a tool, which allow us to mount directory file systems over ssh on Ubuntu. sshfs is a filesystem client based on the SSH File Transfer Protocol.
Most SSH servers already support this protocol it is very easy to set up on the server side there’s nothing to do. On the client side mounting the filesystem is as easy as logging into the server with ssh.

How to install sshfs –

root@arunbagul:~# apt-get  install   sshfs
Reading package lists… Done
Building dependency tree

….
root@arunbagul:~#

This will also install fuse-utils and libfuse2, which are required.

What is required ?

fuse is the kernel module which need to loaded –

root@arunbagul:~# lsmod | grep fuse
fuse 47124 3
root@arunbagul:~#

If this module is not loaded, you will get following error-

fusermount: fuse device not found, try ‘modprobe fuse’ first

** Use below command to load ‘fuse’ module

root@arunbagul:~# modprobe fuse
root@arunbagul:~#

If you want to load ‘fuse’ modules on startup. Then edit the file /etc/modules and adding a ‘fuse’ on new line at the end.

** Now create a local directory where you want the files to be mounted…

root@arunbagul:~# mkdir /media/ssh_file_system
root@arunbagul:~#
root@arunbagul:~# chown arun:arun /media/ssh_file_system
root@arunbagul:~#

Once you have done the above, you can use sshfs to mount the remote directory to your local system!

Say I want to mount the “/var/www” directory on my remote server (192.168.0.1) I would do it by executing the following command…

root@arunbagul:~# sshfs root@192.168.0.1:/var/www /media/ssh_file_system
root@192.168.0.1’s password:
root@arunbagul:~#

** Check with mount command whether the file system is mounted or not

root@arunbagul:~# mount | grep sshfs
sshfs#root@192.168.0.1:/var/www on /media/ssh_file_system type fuse (rw,nosuid,nodev,max_read=65536)
root@arunbagul:~#

NOTE – Normal user should be in ‘fuse’ group to mount file system by using sshfs.

root@arunbagul:~# grep fuse /etc/group
fuse:x:106:
root@arunbagul:~#

** How to unmount the directory –

root@arunbagul:~# mount | grep sshfs
sshfs#root@192.168.0.1:/var/www on /media/ssh_file_system type fuse (rw,nosuid,nodev,max_read=65536)
root@arunbagul:~#

root@arunbagul:~# fusermount -u /media/ssh_file_system
root@arunbagul:~#

root@arunbagul:~# mount | grep sshfs
root@arunbagul:~#

done!

command(1) fusermount – mount FUSE filesystems. A virtual FUSE filesystem will be created on the mount point.

Options
-h print help

-V print version

-o opt[,opt…]
mount options

-u unmount

-q quiet

-z lazy unmount (works even if resource is still busy)

command(2) SSHFS – filesystem client based on SSH File Transfer Protocol

usage: sshfs [user@]host:[dir] mountpoint [options]

general options:
-o opt,[opt…]
mount options

-h –help
print help

-V –version
print version

-p PORT equivalent to ‘-o port=PORT’

Cheers,
Arun Bagul

SSH tunneling – for SOCK proxy port forwarding

SSH tunneling – for SOCK proxy port forwarding

Introduction –

SSH (secure shell) client can be used as “SSH tunneling for SOCK proxy port forwarding“.

ssh -D [bind_address:]port

* -D option in SSH can be used to specifies a local “dynamicapplication-level port forwarding. This works by allocating a socket to listen to port on the local side, optionally bound to the specified bind_address(127.0.0.1). Whenever a connection is made to this port(8080), the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine. Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh will act as a SOCKS server. Only root can forward privileged ports. Dynamic port forwarding can also be specified in the configuration file….

** How to use SSH tunneling for SOCK port forwarding –

root@arunbagul:~# ssh -D 8080 arun@192.168.0.1
arun@192.168.0.1’s password:

….

arun@server:~$
** Check the 8080 port is open or your local system –

root@arunbagul:~# netstat -nlp | grep 8080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN –
tcp6 0 0 ::1:8080 :::* LISTEN –
root@arunbagul:~#

** 8080 is the SOCKS proxy port of your local system. This is a tunnel to the server(192.168.0.1). Now all you have to do is got to set the preference in Firefox browser and use a SOCKS proxy. The proxy is, of course, “localhost”, with the port 8080. Now whenever you browse, all the connections you make to websites will seem to originate from the server to which you SSH-ed(192.168.0.1). In addition, all outgoing and incoming data for the browsing session will be encrypted since it passes through the SSH connection…

Find out what is possible with ssh ?

Cheers,
Arun Bagul

Automation using Macro tools

Automation using Macro tools

Introduction – Automation means making the manual work fully automatic. Any (repeating) manual work on computer applications can be automated using some software. Now I am going to explain the usage of macro tools to perform automation….

I found many automation tools are available to write the automation scripts and run to perform the repeated task. On them I found Imacro Player is one of the best automation tool. Imacro tools can help you for easy web automation in effective manner.
This is used for web applications automation. And will not work for windows based application. For windows based Automation Anywhere is the powerful software, which will create macro on windows. It will run fast and accuratly. Automation Anywhere got many features so that macro can work in network too…

** One of the good advantage is we can use imacro with different programming languages with out any problem. Automation anywhere supporst VB, VC++.

imacro

Thank you,
Santhosh Tirunahari