You are not logged in.

#1 2024-09-03 21:55:01

1ptb3b
Member
Registered: 2017-01-17
Posts: 82

autofs and sshfs with passphrase protected ssh keys

Hello. I've attempted the instructions here: https://wiki.archlinux.org/title/Autofs#Remote_SSH
But, I can't get the remote directory mounted.

I installed the autofs AUR from https://aur.archlinux.org/packages/autofs

I also installed some packages.

$ sudo pacman -S fuse sshfs

I created /etc/modules-load.d/fuse.conf to load the fuse kernel module with this content.

fuse

I did not edit /etc/autofs/auto.master directly, but instead I created a file at /etc/autofs/auto.master.d/sshfs.autofs with this content.

/media/ssh /etc/autofs/auto.ssh uid=1000,gid=1000,--timeout=60

I'm not sure if I need uid=1000,gid=1000. I added it because some random website said that if I run this as root, I need to specify the info of the user running this?

Then I created the file /etc/autofs/auto.ssh with this content.

myrem     -fstype=fuse,rw,allow_other,IdentityFile=/home/user/.ssh/id_ed25519 :sshfs\#user@myrem\:/

I was originally using a password to login into myrem, but now I decided to upload my public key to myrem.

scp ~/.ssh/id_ed25519.pub user@myrem:~/.ssh/authorized_keys

Then I verified that I could login with the key and not using a password. That worked. (ssh user@myrem)

My SSH private key has a passphrase. I would like to keep a passphrase on this key and I would not like to create a separate key.

I enabled the autofs systemd service.

$ sudo systemctl enable autofs.service

And I rebooted my computer.

Then I tried running this command, but it didn't work.

$ ls /media/ssh/myrem
ls: cannot access '/media/ssh/myrem': No such file or directory

Not sure how to debug this. I tried running

$ journalctl -f -t automount -t autofs

but nothing got logged.

Not sure how to proceed from here. Any tips?
I'd really like if I could use my passphrase protected SSH key for this.

UPDATE:
Ah, sorry. I totally missed the debugging section https://wiki.archlinux.org/title/Autofs … unt_issues

I was actually able to get everything mounted by running this command in the foreground.

$ sudo automount -f --debug

But, I had to manually enter my password to unlock the SSH key...

I restarted my computer and tried to ls /media/ssh/myrem, but that didn't work. If I run automount manually and enter my key passphrase then the ls works.

Is there some way to get autofs to ask my SSH agent for the key?

Last edited by 1ptb3b (2024-09-03 22:12:02)

Offline

Board footer

Powered by FluxBB