Notes
How to mount a remote folder over SSH
Say, you need to mount directory ~/mydir
from comp1
to comp2
.
At comp2
, install sshfs package, generate an SSH key with empty passphrase, copy its public key to comp1
, create local mounting point, then modify /etc/fstab
to mount remote location to the mounting point using the generated key.
sudo apt install sshfs
ssh-keygen -b 2048 -t rsa -f ~/.ssh/sshfs_comp1_rsa -q -N ""
ssh-copy-id -i ~/.ssh/sshfs_comp1_rsa comp1
mkdir ~/mydir
user=$(whoami)
echo "
$user@comp1:/home/$user/mydir /home/$user/mydir sshfs allow_other,IdentityFile=/home/$user/.ssh/sshfs_comp1_rsa 0 0
" | sudo tee --append /etc/fstab
sudo mount /home/$user/mydir
Do not forget to replace comp1
with hostname or IP address of your source machine. Also, if you use different usernames on comp1
and comp2
then you will need to adjust the code even further.