Showing posts with label ssh. Show all posts
Showing posts with label ssh. Show all posts

Wednesday, May 28, 2008

automount with sshfs and sshpass

sshfs is great for mounting a remote filesystem and having it appear as a local drive. The major drawback is that it is difficult to automatically mount with sshfs at startup without using ssh keys. Using sshpass, I have worked out a solution.

For this example, let's assume the following parameters:
  • username on remote host: user
  • password on remote host: password
  • remote host: host.com
  • directory: /directory
  • mount point: /media/ssh
In order to accomplish the mount, you will need to create two files:
  1. A file containing just your password, followed by a newline. In the example, I will assume this file is located at /home/user/.pwd. If your password is "password", it should look like this:

    password

  2. A bash script that indicates how to use sshpass. In the example, I will assume that this file is located at /home/user/ssh.sh. Note that the location of your .pwd file must be included after the -f option. This file must be made executable.

    #!/bin/bash
    sshpass -f /home/user/.pwd ssh $*

To mount this from the command line, you could issue the following command:

sudo mount -t fuse sshfs#user@host.com:/directory /media/ssh -o ssh_command=/home/user/ssh.sh

However, the title of this post is automounting, so let's do that. To automount this ssh server, you can add a line like this to your /etc/fstab:

sshfs#user@host.com:/directory /media/ssh fuse ssh_command=/home/user/ssh.sh 0 0

That's it. Pretty cool. Hope you find it as useful as I do.

Friday, May 9, 2008

Ubuntu 8.04 (Hardy) has a gdm ssh client!

Hardy apparently has an ssh client built into gdm, making it easy to login to a remote machine and see your desktop. Seems to work pretty well at the moment, but it would be nice if you could log in to your local machine simultaneously. Something ala NoMachine NX.