How do I pass the root's password to the VM?

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

How do I pass the root's password to the VM?

Peeyush Gupta
Hi all,

I have provisioned a Fedora 19 VM through Vagrant. Now, I am running some command through shell script. Some of these commands require the root's password.

How can I pass the password to the VM? Is there any way to pass argument to the command, so that it will use them whenever necessary?

Thanks,
Peeyush Gupta

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I pass the root's password to the VM?

Simon McCartney
The root password isn't known by Vagrant, but the vagrant user has full
sudo permissions to root (or at least it does in a proper vagrant base box)

Does your script need the root password or just to be run as root?

As vagrant doesn't rely on the root password, your scripts can just set
the password to fit your requirements.

Simon.

Peeyush Gupta wrote:

> Hi all,
>
> I have provisioned a Fedora 19 VM through Vagrant. Now, I am running
> some command through shell script. Some of these commands require the
> root's password.
>
> How can I pass the password to the VM? Is there any way to pass argument
> to the command, so that it will use them whenever necessary?
>
> Thanks,
> Peeyush Gupta
>
> --
> 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 [hidden email].
> For more options, visit https://groups.google.com/groups/opt_out.
--
Simon McCartney
[hidden email]
+44 7710 836 915


signature.asc (275 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

How do I pass the root's password to the VM?

VMTrooper
In reply to this post by Peeyush Gupta
Hello Peeyush,

You can either use "sudo" with your commands or execute "su -" before listing your commands.

If the Vagrant box you are using was built properly, it shouldn't prompt for a password with either of those commands.

-Trevor

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I pass the root's password to the VM?

Peeyush Gupta
Hi Simon,

The script needs the root's password when it is executing the command. So, "sudo" doesn't work and it doesn't even prompt me to enter the password. It just gives me an error.

Trevor,

I tried with both "sudo" and "su -", none of them is working. The thing is, I need to enter the password in order for the command to be executed successfully and that I have to do regardless if I am super-user or not. 

Isn't there any way that the guest VM can prompt me to enter the password when it is executing the command?

Thanks,
Peeyush Gupta


On 28 November 2013 17:08, Trevor Roberts <[hidden email]> wrote:
Hello Peeyush,

You can either use "sudo" with your commands or execute "su -" before listing your commands.

If the Vagrant box you are using was built properly, it shouldn't prompt for a password with either of those commands.

-Trevor

--
You received this message because you are subscribed to a topic in the Google Groups "Vagrant" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vagrant-up/Ox_Usw9A-fY/unsubscribe.
To unsubscribe from this group and all its topics, send an email to [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.



--
~Peeyush Gupta

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.
Reply | Threaded
Open this post in threaded view
|

Re: How do I pass the root's password to the VM?

Simon McCartney


Peeyush Gupta wrote:

> Hi Simon,
>
> The script needs the root's password when it is executing the command.
> So, "sudo" doesn't work and it doesn't even prompt me to enter the
> password. It just gives me an error.
>
> Trevor,
>
> I tried with both "sudo" and "su -", none of them is working. The thing
> is, I need to enter the password in order for the command to be executed
> successfully and that I have to do regardless if I am super-user or not.
>
> Isn't there any way that the guest VM can prompt me to enter the
> password when it is executing the command?
No, but can you pipe in the password?

can you run something like this?

ROOTPW="rootpasswordhere"
echo ${ROOTPW} | passwd --stdin root
echo ${ROOTPW} | /some/script.sh

Or if you pass the password on the command line:

ROOTPW="rootpasswordhere"
echo ${ROOTPW} | passwd --stdin root
/some/script.sh ${ROOTPW}



Simon.

--
Simon McCartney
[hidden email]
+44 7710 836 915


signature.asc (275 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How do I pass the root's password to the VM?

Peeyush Gupta
Nah, it's not working. Will have to find some other way. Anyways, thanks for the effort.

Thanks,
Peeyush Gupta


On 28 November 2013 17:38, Simon McCartney <[hidden email]> wrote:


Peeyush Gupta wrote:
> Hi Simon,
>
> The script needs the root's password when it is executing the command.
> So, "sudo" doesn't work and it doesn't even prompt me to enter the
> password. It just gives me an error.
>
> Trevor,
>
> I tried with both "sudo" and "su -", none of them is working. The thing
> is, I need to enter the password in order for the command to be executed
> successfully and that I have to do regardless if I am super-user or not.
>
> Isn't there any way that the guest VM can prompt me to enter the
> password when it is executing the command?

No, but can you pipe in the password?

can you run something like this?

ROOTPW="rootpasswordhere"
echo ${ROOTPW} | passwd --stdin root
echo ${ROOTPW} | /some/script.sh

Or if you pass the password on the command line:

ROOTPW="rootpasswordhere"
echo ${ROOTPW} | passwd --stdin root
/some/script.sh ${ROOTPW}



Simon.

--
Simon McCartney
[hidden email]
+44 7710 836 915




--
~Peeyush Gupta

--
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 [hidden email].
For more options, visit https://groups.google.com/groups/opt_out.