How to connect to an SSH share on boot using SSHFS

For those that do not know SSH or Secure Shell is a networking protocol with uses encryption. There are different ssh clients available however openssh-client is the most popular also comes pre-installed with most linux distrobutions. The server package however in most cases does not as this give be a security risk , so to install this package on a debian/ubuntu host (the computer that has the share) open a terminal and sudo apt-get install openssh-server on other linux systems the package is usually the same name. After the package has been installed we should be able to go to the client (computer you’re wanting to connect from). A quick restart of the networking might need to be done at this point so sudo service networking restart

With that installed now we can connect in terminal with ssh user@ip.address , obivously user is the user you want to connect too and ip.address is the ip address of the host. For security reasons never allow the root user to be accessed over ssh , don’t worry most linux distrobutions have this disabled by default. After runnning ssh user@ip.address you will be prompted for a password , that is their user password.

If like me you don’t want people to be able to know your user password this where we can create a set of keys where your password is stored and if desired another password can be used instead. To accomplish this open terminal on the host and as the user you want to connect with ssh-keygen , you will then be prompted with , where you would like to save the file , no need to really change this. You will then be prompted for passphrase , leave it empty if you you want to add an entry to fstab later. The next step is to copy the .pub file to the client(s) that want to connect to the host computer , this file goes into /home/user/.ssh/authorized_keys. The authorized_file can contain keys for more than one client , just copy the .pub file from other client and copy them into that file.

The next step is to install sshfs (on the client) so that we can access the host computers share(s) , if on debian/ubuntu based linux open a terminal and sudo apt-get install sshfs . Once installed we need to create a mountpoint i would recommend in /mnt , something like sudo mkdir /mnt/Share also make sure you user has access to it , so sudo chown -R root:root /mnt/Share and then add user to the ‘root’ group. If all that has been setup we can now sshfs user1@ip.address:/path/to/share /mnt/Share. I would also recommend that the share is located in /mnt on the host and that user1 has access to it whether read/write or just read.

With that all working we can now acces the network share in /mnt/Share , which is fine but if you want to connect to it everytime you boot and dont want to have to type sshfs user1@ip.address:/path/to/share /mnt/Share everytime you login we can add an entry to fstab so that we can do this , the entry will look something like sshfs#user1@ip.address:/share /mnt/Share fuse user,allow_other 0 0.

Tagged with:
Posted in 01Ben, Computers
4 comments on “How to connect to an SSH share on boot using SSHFS
  1. mickeyj4j says:

    Wow Keep up the excellent posts ben.

  2. […] And that is how I setup my desktop so that I could securely access my desktop and/or webcam whilst on holiday. I would also recommend setting up an encrytped key pair for ssh , so that know one can see you typing your password. I have previously explained how to do that here , […]

  3. […] expected. The other solution would have been to create ssh-keys without a password like I did here You might find that ssh-askpass looks a bit ugly so there are other better looking options […]

  4. yahoo says:

    I’m really impressed with your writing skills as well as with the layout on your blog.

    Is this a paid theme or did you customize it yourself?
    Either way keep up the excellent quality writing, it’s rare to see a great blog like this one today.

Please feel free to leave a reply.

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Enter your email address to follow this blog and receive notifications of new posts by email.

Join 67 other followers

%d bloggers like this: