Skip to content

Instantly share code, notes, and snippets.

@danigiri
Last active November 11, 2015 10:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danigiri/b07d367f77c4c84410bd to your computer and use it in GitHub Desktop.
Save danigiri/b07d367f77c4c84410bd to your computer and use it in GitHub Desktop.
Fuse sshfs on Centos7 with minimum hassle
# sshfs cheatsheet for vms in centos7
# host IP in the vm network
export IP=192.168.46.1
# vm IP
export VMIP=192.168.46.132
#host user
export USER_=dani
# host GIT folder
export SOURCE="/Users/$USER_/Documents/GIT"
# home on vm
export DEST="/home/$USER_"
sudo yum install epel-release-7
sudo yum install sshfs
echo 'fuse' > /etc/modules-load.d/fuse.conf
echo "$USER_@$IP:$SOURCE $DEST/GIT fuse.sshfs x-systemd.automount,_netdev,user,exec,idmap=user,transform_symlinks,identityfile=/home/dani/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000 0 0" \
>> /etc/fstab
echo "$USER_@$IP:/Users/$USER_/.m2/repository $DEST/.m2/repository fuse.sshfs x-systemd.automount,_netdev,user,idmap=user,transform_symlinks,identityfile=/home/$USER_/.ssh/id_rsa,allow_other,default_permissions,uid=1000,gid=1000 0 0" \
>> /etc/fstab
# Important: DO THIS FIRST AS ROOT to add to known hosts as root and then it does not hang!!!
ssh $USER_@$IP
# TODO: it could be done to add the entry to known hosts with cat >>
# mount point
mkdir GIT
ssh-keygen -t rsa
cat .ssh/id_rsa.pub | ssh $USER_@$IP 'cat >> .ssh/authorized_keys'
# optional handy stuff (as root)
yum install vim -y -q
echo 'dani ALL=(ALL) ALL' > /etc/sudoers.d/$USER_
# Handy stuff (from host)
cat ~/.ssh/id_rsa.pub|ssh $USER_@$VMIP 'cat >> ~/.ssh/authorized_keys'
# Handy stuff
mkdir .ssh && chmod 700 .ssh
touch .ssh/authorized_keys && chmod 600 .ssh/authorized_keys
sudo yum install git zsh -y -q
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@danigiri
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment