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

85 views
Skip to first unread message

Peeyush Gupta

unread,
Nov 28, 2013, 6:23:07 AM11/28/13
to vagra...@googlegroups.com
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

Simon McCartney

unread,
Nov 28, 2013, 6:38:05 AM11/28/13
to vagra...@googlegroups.com
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.
> --
> 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 vagrant-up+...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

--
Simon McCartney
si...@mccartney.ie
+44 7710 836 915

signature.asc

Trevor Roberts

unread,
Nov 28, 2013, 6:38:31 AM11/28/13
to vagra...@googlegroups.com
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

Peeyush Gupta

unread,
Nov 28, 2013, 6:50:03 AM11/28/13
to vagra...@googlegroups.com
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



--
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 vagrant-up+...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
~Peeyush Gupta

Simon McCartney

unread,
Nov 28, 2013, 7:08:05 AM11/28/13
to vagra...@googlegroups.com


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.
signature.asc

Peeyush Gupta

unread,
Nov 29, 2013, 12:49:03 AM11/29/13
to vagra...@googlegroups.com
Nah, it's not working. Will have to find some other way. Anyways, thanks for the effort.

Thanks,
Peeyush Gupta
--
~Peeyush Gupta
Reply all
Reply to author
Forward
0 new messages