Skip to content

Instantly share code, notes, and snippets.

@jaredmcateer
Created June 24, 2014 18:35
Show Gist options
  • Save jaredmcateer/a2e9f7cb91d2d5ada7ca to your computer and use it in GitHub Desktop.
Save jaredmcateer/a2e9f7cb91d2d5ada7ca to your computer and use it in GitHub Desktop.
# First you need to change the root password so you can ssh in as root
vagrant ssh
sudo su
passwd
root
root
exit
# On your host machine:
# ---------------------
# Make note of the uid and gid (referenced as: host_uid, host_gid)
getent passwd | grep "<yourusername>"
# outputs: <username>:x:<uid>:<gid>:...
# ssh into vagrant box as adming
ssh root@dev-stuby
# On your guest machine:
# ----------------------
# Make note of the vagrant uid/gid (referenced as: vagrant_uid, vagrant_gid)
getent passwd | grep "vagrant"
# Make note of the user/group on the guest machine that machine that matches your host machine
# (referenced as: guest_user, guest_group)
getent passwd "<host_uid>" | cut -d: -f1
getent group "<host_gid>" | cut -d: -f4
# Move current guest occupying host uid/gid
usermod -u 60000 <guest_user>
groupmod -g 60000 <guest_group>
find / -user <host_uid> -exec chown -h 60000 {} \;
find / -group <host_gid> -exec chown -h 60000 {} \;
usermod -g 60000 <guest_user>
# Move vagrant to match host
usermod -u 60000 <vagrant_user>
groupmod -g 60000 <vagrant_group>
find / -user <vagrant_uid> -exec chown -h <host_uid> {} \;
find / -group <vagrant_gid> -exec chown -h <host_uid> {} \;
usermod -g 60000 <vagrant_user>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment