I'd like to be able to mount my backup server on-demand by using my keys on my client terminal only as I don't leave my SSH keys on servers I manage. Does SSHFS support ssh-gent forwarding and how?
Didn't find answers to that in the documentation.
Thanks in advance!
Yes, it supports. You only need to have agent forwarding enabled. SSHFS is transparent to it, if it works for your system than it works also for SSHFS.
Here is the proof:
[root@novaprime ~]# ssh -A hercules Last login: Tue Jan 22 23:46:47 2019 from gateway [root@hercules ~]# sshfs -o allow_other [email protected]:/ /mnt [root@hercules ~]# df -Ph /mnt Filesystem Size Used Avail Use% Mounted on [email protected]:/ 49G 9.0G 40G 19% /mnt [root@hercules ~]#
Okay, just solved the issue. Thing is that I executed
sshfs
command viasudo
, as root, so my user environment (SSH_* variables) wasn't accessible to root so I added my user SSH enviroment variables tosudoers
file:After logging in again and running sshfs as root my keys were forwarded to the server properly.
Not sure if this is the most secure thing in the world but I'm open to suggestions to solve this properly.
This can be done temporarily, on a per use case by using
-E
man pageFor example, if you're a regular user on
host
This forwards your agent connection from
client
throughhost
tohost2
.sudo
allows the environment to be preserved when executingsshfs