Rogue login as root by default

Problem: Often the first command I entered in my fields is su - .

Question: how to make vagrant ssh the default root user?

Version: vagrant 1.6.5

+59
login vagrant ssh root
Sep 10 '14 at 6:31
source share
7 answers

Decision:
Add the following to your Vagrantfile :

 config.ssh.username = 'root' config.ssh.password = 'vagrant' config.ssh.insert_key = 'true' 

When you continue to vagrant ssh , you will be logged in as root and should expect the following:

 ==> mybox: Waiting for machine to boot. This may take a few minutes... mybox: SSH address: 127.0.0.1:2222 mybox: SSH username: root mybox: SSH auth method: password mybox: Warning: Connection timeout. Retrying... mybox: Warning: Remote connection disconnect. Retrying... ==> mybox: Inserting Vagrant public key within guest... ==> mybox: Key inserted! Disconnecting and reconnecting using new SSH key... ==> mybox: Machine booted and ready! 

Update 23-Jun-2015: This also works for version 1.7.2. Key security improved from 1.7.0; this method overrides the previous method that uses the well-known private key. This solution is not intended to be used in a box that is publicly available without the appropriate security measures taken prior to publication.

Link:

+87
Sep 10 '14 at 6:31
source share

this is useful:

 sudo passwd root 

... for those who were caught because of the need to set the root password in the roaming first

+81
Jan 16 '15 at
source share

This works if you are in the ubuntu / trusty64 field:

 vagrant ssh 

Once you get into the ubuntu field:

 sudo su 

You are now the root user. You can update the root password as shown below:

 sudo -i passwd 

Now edit the line below in the file /etc/ssh/sshd_config

 PermitRootLogin yes 

It’s also convenient to create your own alternate username:

 adduser johndoe 

Wait until it asks for a password.

+13
Jun 01 '16 at 3:40
source share

Do not forget that root is allowed root to login earlier !!!

Put the configuration code below in the / etc / ssh / sshd _config file.

 PermitRootLogin yes 
+5
Jan 30 '16 at 8:43
source share

If Vagrantfile as below:

 config.ssh.username = 'root' config.ssh.password = 'vagrant' config.ssh.insert_key = 'true' 

But the tramp still asks you for the root password, most likely the base box you used is not configured to register root.




For example, the official ubuntu14.04 mailbox does not set PermitRootLogin yes to /etc/ssh/sshd_config .

So, if you want the box to be able to log in as root by default (only Vagrantfile, no more work), you should:

  • Install vm by vagrant (any name except root)

  • Log in and edit the sshd configuration file.

    ubuntu: edit /etc/ssh/sshd_config , install PermitRootLogin yes

    orthers: ....

    (I only use ubuntu, feel free to add workarounds for other platforms)

  • Create a new base box:

     vagrant package --base your-vm-name 

    create package.box file

  • Add this base box for strollers:

     vagrant box add ubuntu-root file:///somepath/package.box 

    then you need to use this base unit to create vm, which allows you to automatically enter the user as root user.

  • Destroy the original vm vagrant destroy

  • Change the original Vagrantfile , change the field name to ubuntu-root and the username to root , then create a new vagrant up .

I had time to find out, it is too complicated, in my opinion. Hope the tramp will improve this.

+5
Nov 08 '16 at 3:22
source share

I know this is an old question ... but, looking at the original question, it looks like the user just wanted to run the command as root .. what should I do when I looked for the answer and stumbled across the whole question.

So, it’s worth knowing, in my opinion:

vagrant ssh servername -c "echo vagrant | sudo -S shutdown 0"

"tramp" is the password passed to the sudo command because, as we all know, the roaming account has sudo privilages, and when you are sudo, you need to specify the password of the user account, not root .. and of course, by default , the password of roaming users is "roaming"!

By default, you need root privilages to shut down, so I think closing is a good test.

Obviously, you do not need to provide a server name if there is only one for this wandering environment. In addition, we are talking about the local vagutal virutal machine for the host, so there is no security problem that I can see.

Hope this helps.

0
Feb 26 '17 at 19:23
source share
 vagrant destroy vagrant up 

Please add this to the roaming file:

 config.ssh.username = 'vagrant' config.ssh.password = 'vagrant' config.ssh.insert_key = 'true' 
-four
11 Oct. '15 at 4:51 on
source share



All Articles