I connect to my home server with ssh server
, where server is configured in ~/.ssh/config
as:
Host server
HostName {server-address}
User me
IdentityFile ~/.ssh/id_rsa
IdentityFile
is a passphrase-protected private key, so I have to enter my passphrase every time I log in.
I can locally mount the remote file system on that server with sshfs me@{server-address}:/home/me /mnt/server
. Once again, I have to enter my passphrase to log in with my private key. I notice that I don't need to actually specify the key in the sshfs
options - presumably ~/.ssh/id_rsa
is just the default location?
Finally, to easily mount the system, I added the below line to /etc/fstab
:
me@{server-address}:/home/me /mnt/server fuse.sshfs IdentityFile=/home/me/.ssh/id_rsa,defaults,noauto 0 0
And this lets me simply run mount /mnt/server
to mount the filesystem - and of course, I'm asked for my passphrase.
Note that I had added the noauto
option so that it wouldn't be mounted on boot, as I was worried the system would hang if it couldn't mount the filesystem without the passphrase.
Is my suspicion right here? Will the system fail to boot if it tried to mount the server filesystem, but didn't get the passphrase? Is there a way that I can supply the passphrase to /etc/fstab
/ the mount
command, so that it will be able to boot the filesystem on boot?
I would like to give an alternative to the only answer in this question. Instead of creating a new keypair (this time without protecting the private key), it is possible to remove a passphrase from the existing private key.
Just do
$ ssh-keygen -p
. After removing the password, sshfs in fstab works flawlessly.My final sshfs fstab like is USER@SERVER:/folder /mnt/sshfsmount fuse.sshfs noauto,x-systemd.automount,_netdev,allow_other,IdentityFile=/home/USER/.ssh/id_rsa,reconnect,follow_symlinks 0 0