How to use SSHFS with root with a Vagrant Debian
1 min readJul 19, 2018
Hello,
First we modify configuration of openssh-server to allow connection with root. So we change this line in /etc/ssh/sshd_config
:
PermitRootLogin yes
Then we restart the SSH server:
sudo systemctl restart ssh
We have to copy the SSH private key in root home folder. The simplest is to do that:
sudo cp -r ~/.ssh /root/
To connect to the server easily, we’ll use a ssh config file. Vagrant can generate content of it:
$ vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /home/authmane512/domopi-vm/.vagrant/machines/default/virtualbox/private_key
IdentitiesOnly yes
LogLevel FATAL
We change this line:
User root
You can also change host name to what you like:
Host MyVagrantVM
And put that in .ssh/config
folder.
Now to connect, we only need to do:
$ ssh MyVagrantVM
Linux stretch 4.9.0-6-amd64 #1 SMP Debian 4.9.82-1+deb9u3 (2018-03-02) x86_64root@stretch:~#
So to use SSHFS, do:
sudo mkdir /media/ssh
sudo chmod 777 /media/ssh
sshfs MyVagrantVM:/home/vagrant /media/ssh
To unmount:
sudo umount /media/ssh
That’s all!