SSHFS is a filesystem, that works over a SSH tunnel.
In order to mount a remote file system (e.g. from your development host) on your local account on the main host (bren) issue these commands:
$ ssh-copy-id -i ~/.ssh/id_rsa.pub username@host $ mkdir <-p> <mountpoint> $ sshfs <username>@<hostip>:/home <mountpoint>
where the ssh-copy-id copies your public ssh-key to the remote host and where ~/.ssh/id_rsa.pub is where your ssh keys resides. If there are no id_rsa.pub you should generate a pair of keys:
just hit enter to all prompts.
Then you shall create the mountpoint - that is the directory on where you will mount the remote filesystem. The -p creates all directories if they do not exists.
Finally issue the sshfs command to mount the remote file system on the mountpoint.
SSHFS in autofs
In order to have sshfs's automounted follow these instructions:
$ groupadd fuse $ usermod -a -G fuse <your-loginname>
Ensure that you have access to login on the remote server over ssh.
$ ssh <your-loginname>@<remote-host>
If you were prompted for the password create and distribute a public key as described in the section above. Next:
$ ssh-copy-id -i ~/.ssh/rsa_id.pub <your-loginname>@<remote-host>
Re-test that you can login.
Create a directory to mount your remote filesystems on. Ex. ~/mounts
Next grep in /etc/passwd for your loginname
$ grep /etc/passwd <your-loginname> <your-loginname>:x:500:500:Yourname:....
This indicates that your uid and gid is 500 or whatever you read on your *nix.
I have two servers to automount bren and merlin.
Add to the end of /etc/auto.master
/home/klaus/mounts/sshfs/au-herning /etc/auto.bren.sshfs uid=500,gid=500,--timeout=600,--ghost /home/klaus/mounts/sshfs/merlin /etc/auto.merlin.sshfs uid=500,gid=500,--timeout=600,--ghost
The timeout can be varied - in this example I have set it rather long, because for example my texteditors usually autosaves every 5 minutes = 300s. If the automount timeout were shorter than this the directory is automagically unmounted and the text editor has to wait for a remount.
Now create /etc/auto.bren.sshfs and auto.merlin.sshfs and add one line per remote share you want to mount.
m -fstype=fuse,rw,nodev,nonempty,noatime,allow_other,max_read=65536 :sshfs\#firstname.lastname@example.org\:/home/klausk
and likewise for the merlin server.
m can be anything, e.g. au-herning or just m to make it short. The ~/sshfs/au-herning directory will be created when automount starts. The m directory is mounted when the au-herning is accessed. Below m is the structure of your remote server.
Now create the root for the automount to work on.
Logged in as your self issue:
$ mkdir -p ~/mounts/sshfs
The sub-directories on the sshfs directory will be created by automount.
Finally start the automount program in debug mode as root:
$ automount -f -v
observe that the are no errors.
Kill the program by Ctrl+C
Activate automount such it will start at boot.
$ systemctl enable autofs.service $ # and start it $ systemctl start autofs.service
Reboot your computer and ensure that the automounting is working correct. Logged in as your ordinary login, issue:
$ ls mounts/sshmount/au-herning # some output here after a few seconds
Tftp booting at home directly from your development host
Now the filesystem on the remote development host is available on your primary host (bren).
Since bren is accessible from the outer world through port 2222 with ssh you can mount your sshfs mounted share on bren on your home computer.
Home computer/tftpboot -- sshfs --> bren/your share -- sshfs --> development host/ /home/emb/uClinux-dist/images
and your EA board can boot directly from your development host, provided you install a tftp server on your local machine and let it share from /tftpboot. Remember to set up the EA board to work in your local network.
First follow the instructions above and mount the disk on your development host on a directory in your home directory.
The uid and gid's mentioned below may vary on your computer. Check locally in /etc/passwd and /etc/group your uid and gid.
local host$ sshfs -o uid=500 -o gid=500 -p 2222 <your login on bren>@bren.hih.au.dk:<your mounted disk from the development host> <mountpoint> local host$ ln -s <mountpoint>/<path-to-uClinux-dist>/images /tftpboot
If your tftp server is set up to serve from /tftpboot as suggested above your EA board now loads on your local network directly from the development host.
You can put the IP address for bren.hih.au.dk in your local /etc/hosts file.