Hello.

Vagrant requires ssh to connect to the AWS box.

So you can use the keys that AWS give you.

If the AMI you want to use is not fit, and need some changes, then you can
use packer to configure it and create a new ami:
https://www.packer.io/

Alvaro.

On Sat, Jan 23, 2016 at 3:30 AM, Byron Kim <[email protected]> wrote:

> So I know you can use the following to run as a different user:
>
> config.ssh.username = "ubuntu"
> config.ssh.private_key_path = File.expand_path("../ssh_key", __FILE__)
>
>
> I'm provisioning the default ubuntu/trusty64 on Virtualbox and if i use
> the --provider=aws flag, it will spin up an EC2 instance.  I'm also using
> Ansible to configure the VM/instance.
>
> The problem I'm running into is using the 'ubuntu' user to be configured.
> I was hoping that there is a way to run a shell script prior to vagrant
> ssh'ing into the Virtualbox.  I tried running this as a shell script:
>
> sudo cp -f /vagrant/ssh_key /home/ubuntu/.ssh/authorized_keys
> sudo sed -i '/PasswordAuthentication yes/c\PasswordAuthentication no' /etc
> /ssh/sshd_config
> sudo service ssh restart
>
> But I believe vagrant will try to ssh first and then run the shell
> script.  Is there any way around this or do I have to build my own vagrant
> box and have this setting in place?
>
> The reason I need to do this is because I'm referencing files in my
> Ansible playbook and it doesn't always interpret ~/ with the correct
> directory.  I could write out the whole path, vagrant's home path is
> /home/vagrant/ and the EC2 instance is /home/ubuntu/ and that would look
> messy.  I'm not 100% sure how I can have conditionals in place (as in
> Ansible knowing I'm running this on Virtualbox or AWS).
>
> --
> This mailing list is governed under the HashiCorp Community Guidelines -
> https://www.hashicorp.com/community-guidelines.html. Behavior in
> violation of those guidelines may result in your removal from this mailing
> list.
>
> GitHub Issues: https://github.com/mitchellh/vagrant/issues
> IRC: #vagrant on Freenode
> ---
> You received this message because you are subscribed to the Google Groups
> "Vagrant" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/vagrant-up/d05e2e8f-7631-4b44-b617-ff9d7c830c2c%40googlegroups.com
> <https://groups.google.com/d/msgid/vagrant-up/d05e2e8f-7631-4b44-b617-ff9d7c830c2c%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
This mailing list is governed under the HashiCorp Community Guidelines - 
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of 
those guidelines may result in your removal from this mailing list.

GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
--- 
You received this message because you are subscribed to the Google Groups 
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CAHqq0ewwPORR-0agra%3Ddi7tAEYjVqO2-t47RKAU89qFRYvJTpw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to