mounting $HOME and setting config.ssh.username=$USER

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

mounting $HOME and setting config.ssh.username=$USER

Jay Buffington
Hello,

I would like to mount $HOME and use $USER to ssh to my vm using the
~/.ssh/authorized_keys file that gets mounted.

I was able to configure vagrant to mount my home directory with the following
lines in my Vagrantfile:

  config.vm.share_folder "jaybuff-home", "/home/jaybuff", "/Users/jaybuff",
                         :owner=> 'jaybuff', :group=>'jaybuff'

Once I created the VM and that home directory was mounted I set
config.ssh.username to jaybuff and (after disabling selinux) I was able to ssh
in using key based auth with "vagrant ssh"  Great!

The problem with this is that rebooting the VM or creating a new one causes
failures because vagrant itself can't ssh in as jaybuff until the home directory
is mounted.  Since it uses the config.ssh.username is used to mount the home 
directory, this is a chicken and egg problem.

I see two solutions to this problem:

  1) use 'config.ssh.username' for 'vagrant ssh' and a separate option such as
    'config.ssh-communicator.username' which is used by vagrant internally and
     defaults to config.ssh.username
  2) write an alternative communicator that doesn't use ssh to mount shared
     folders.  Perhaps it's possible to mount the root partition locally and fix
     up /etc/fstab.

Thoughts?

Jay
Reply | Threaded
Open this post in threaded view
|

mounting $HOME and setting config.ssh.username=$USER

Nicholas Robinson-Wall
Could you perhaps bake in your public key in to /home/jaybuff/.ssh/authorized_keys of your base box, then leave everything else as-is? I assume you've already gone so far as to customise your base box to have a user called jaybuff.

That should result in the initial login by vagrant as your user being successful, then it will do the vboxsf mount over the top of /home/jaybuff.

-Nick
Reply | Threaded
Open this post in threaded view
|

Re: mounting $HOME and setting config.ssh.username=$USER

Jay Buffington
Thanks for the reply, Nick.  That works for me.  It wasn't really my key that I had to put in the unmount /home/jaybuff/.ssh/authorized_keys it was the key pointed to by config.ssh.private_key_path

While this works great for base boxes that have the jaybuff user added, I was hoping to write a simple shell provisioner to add $USER to /etc/passwd and sudoers so I could make this generic.  I think that won't be possible to do that until I have some way to either control what user provisioners run as or to avoid using ssh to do the provisioning.

Thanks,
Jay

On Wednesday, January 23, 2013 2:40:05 AM UTC-8, Nicholas Robinson-Wall wrote:
Could you perhaps bake in your public key in to /home/jaybuff/.ssh/authorized_keys of your base box, then leave everything else as-is? I assume you've already gone so far as to customise your base box to have a user called jaybuff.

That should result in the initial login by vagrant as your user being successful, then it will do the vboxsf mount over the top of /home/jaybuff.

-Nick

--