Xaero.org Tech news, reviews, and whatever else I wanna put here!

4Sep/110

Using sshfs on FreeBSD

Yep, been a while since I've last posted something (actually this would be the first thing I've posted in 2011), but indispensable utilities like this one motivate me to post more often.

sshfs is part of the FUSE project for implementing file systems in userspace. A file system is typically run in kernel space, both because it gets more tightly integrated with the kernel and it becomes more transparent to the user. Running a file system in userspace alongside applications is a fairly new concept but it works surpringly well.

sshfs is easily installed from the ports system:

cd /usr/ports/sysutils/fusefs-sshfs; sudo make config-recursive; sudo make install clean

is all that's needed. With that step completed, enable mounting file systems devices as a normal user:

#sysctl vfs.usermount=1

I recommend sticking that in /etc/sysctl.conf (omitting the sysctl : ) to make it permanent . Lastly, add 'fusefs_enable="YES"' to your /etc/rc.conf and run /usr/local/etc/rc.d/fusefs start to load the fusefs kernel module that was built with the port.

In order to mount remote machines over ssh, you'll use the sshfs utility. I highly recommend setting up password-less ssh login using a public/private key pair. A simple Google search will show you how that's done. As a first example of mounting a remote server (don't try to mount something from your local machine. weirdness will ensue.), use the following:

%sshfs remotebox: local_dir

Notice the colon after the remote machine. By default, sshfs will try to mount your home directory on the remote server as the local_dir. You can specify any paths your user would normally have access to:

%sshfs remotebox:/usr/src local_dir

The command above would mount the /usr/src directory on the remote machine as /usr/home/<your user>/local_dir. To unmount a directory, the documentation states that you should use fusermount -u <mountpoint> but I was perfectly ok using the normal umount command. To keep the mountpoint available, it's worth adding a keepalive to your ssh client configuration. Simply add something like ServerAliveInterval 5 to your ~/.ssh/config file to send keepalives every 5 seconds to the server.

Enjoy!

20Jul/090

Note to self: pay your bills!

I SSH between my many computers several times in the course of a day. Today when I went to SSH to my web server I couldn't quite figure out what was wrong. I could ping the IP address but SSH just didn't want to work. I tried restarting the SSH daemon and when that didn't work, I rebooted the entire box. After it still didn't work, it finally hit me: I forgot to renew my domain name and it was set to expire on July 17th! To confirm, I did a simple dig lookup:

; <<>> DiG 9.4.2-P2 <<>> xaero.org
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46405
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 2, ADDITIONAL: 0

;; QUESTION SECTION:
;xaero.org.                     IN      A

;; ANSWER SECTION:
xaero.org.              85511   IN      A       69.46.228.231

;; AUTHORITY SECTION:
xaero.org.              85511   IN      NS      expired-domain-ns50.directnic.com.
xaero.org.              85511   IN      NS      expired-domain-ns51.directnic.com.

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Mon Jul 20 13:08:14 2009
;; MSG SIZE  rcvd: 124

Oops!! Needless to say, I very quickly renewed my domain name and within a few short hours my nameservers were happily serving up DNS again. Thankfully my registrar provides a grace period for renewing expired domains so they don't immediately get thrown back into the available pot. Next time I'll stamp a sticky note on my forehead.