Hello,

Once you add the key to the box, and then update the vagrant, do a vagrant ssh

also add:
config.ssh.insert_key = false

it should work,

but it won't work on new boxes, since the user/key doesn't exist on the base box

what you need to do once you add the key to the box, is repackage and
create a new box

make sense?


On Mon, Jul 6, 2015 at 9:06 PM, Shash <[email protected]> wrote:
> Hi,
>
> I would like to use my own key.
>
>
> What I have done so far
>
> Created a user in my guest machine.
> Created ssh key in my host using ssh-keygen
> Copied the ssh key to the guest using ssh-copy-id -p 2222 -i [email protected]
>
> and the part of the Vagrantfile looks like this
>
>
>  config.vm.box = "ubuntu/trusty64"
> config.ssh.username = "shash"
> config.ssh.forward_agent = true
> config.ssh.private_key_path = "~/.ssh/authorized_keys"
>
>
>
>
> I can use
>
> ssh -p '2222' '[email protected]'
>
> to login directly but when I give
> vagrant up
>
> I keep getting the following error
>
> default: Warning: Connection timeout.
> Retrying... default: Warning: Authentication failure.
> Retrying... default: Warning: Authentication failure. Retrying...
>
>
> Any help in sorting out this is really appreciated.Thanks!
>
>
>
> On Monday, July 6, 2015 at 2:38:09 AM UTC+5:30, Alvaro Miranda Aguilera
> wrote:
>>
>> Hello,
>>
>> You require 2 options.
>>
>> 1.  user + vagrant insecure key
>> 2. user + known password
>>
>> Documentation is here:
>> https://docs.vagrantup.com/v2/vagrantfile/ssh_settings.html
>>
>> Option 1.
>>
>> in the Vagrantfile you need to add:
>> config.ssh.username = user
>>
>> in the base box under this user you need to add the vagrant insecure
>> key, which is what vagrant use to connect:
>>
>> Assuming the box is linux, these are the commands I use to add vagrant
>> and to include the ssh key. Please modify to suit your box:
>>
>>       "useradd vagrant",
>>       "cp /etc/sudoers /etc/sudoers.orig",
>>       "sed -i -e '/# %wheel\tALL=(ALL)\tNOPASSWD: ALL/a
>> %vagrant\tALL=(ALL)\tNOPASSWD: ALL' /etc/sudoers",
>>       "mkdir ~vagrant/.ssh",
>>       "chmod 700 ~vagrant/.ssh",
>>       "echo 'ssh-rsa
>>
>> AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ==
>> vagrant insecure public key' > ~vagrant/.ssh/authorized_keys",
>>       "chmod 600 ~vagrant/.ssh/authorized_keys",
>>       "chown -R vagrant: ~vagrant/.ssh"
>>
>>
>> Option 2.
>>
>> In the Vagrantfile add:
>> config.ssh.username = user
>> config.ssh.password = somepassword
>>
>> Let me know if you run into any issues.
>>
>> Alvaro
>>
>> On Mon, Jul 6, 2015 at 7:36 AM, Shash <[email protected]> wrote:
>> > Hi All,
>> >
>> > I am new to this group and I have been trying out vagrant from past
>> > couple
>> > of months.
>> >
>> >  I would like to have a passwordless ssh to another user in the vagrant
>> > guest. I tried a lot looking into various forums but in vain.
>> >
>> > Can someone explain me here how to get this done.
>> >
>> > Thanks!
>> > Shash
>> >
>> > --
>> > 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/5686270f-c2c1-4c2e-b46c-08638177655d%40googlegroups.com.
>> > 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/9efc16d1-a1d2-4634-8371-8d403b0c39ef%40googlegroups.com.
> 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/CAHqq0ewzBpMGyUKR5abQWCpirmwsPc1KKkYaFyVunksBWeXdzw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to