Giter Club home page Giter Club logo

Comments (16)

Hulmani avatar Hulmani commented on July 2, 2024 1

@xinglunxu I tried and yes it works.
Cheers

from ole--vagrant-community.

dogi avatar dogi commented on July 2, 2024

Change Vagrantfile so that the reverse of standard password vagrant is the new password.

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

So, you want to insert this inside Vagrantfile?
config.ssh.password = "tnargav"
Not sure if I get your point correctly.

from ole--vagrant-community.

dogi avatar dogi commented on July 2, 2024

I am on some communities exposing ports to the big internet ;)

@xinglunxu : where exactly in the "Vagrantfile" to I have to put that in ... context is missing ;(

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

Here is the reference to how to configure the ssh connection from vagrant to the vm
To change the ssh password, we can just put the setting
config.ssh.password = "tnargav"
anywhere under
Vagrant.configure(2) do |config|

from ole--vagrant-community.

dogi avatar dogi commented on July 2, 2024

@xinglunxu thx

you have the go for it ;)

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

@dogi So After I inserted this line and tried to reload the machine, an error like this happened.
screen shot 2016-07-06 at 7 03 15 pm
I still haven't figure out how to solve it.
But before that, may I ask why are we changing the password of the vagrant ssh?
What is the problem we are trying to solve in this issue post?
I looked at the link from #2 (comment)
But I still didn't get the problem. 😅

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

Yo, I finally found a way to change the password for ssh by script. But I am almost positive that there is a better way to do this.

So previously, I tried to add config.ssh.password = "tnargav" into Vagranfile to change the ssh password for vagrant. However, all it does is just change the password that Vagrant uses to ssh the vm. The ssh password of user vagrant will still be unchanged in the vm. That is why there is a connection problem in my previous post.

IMHO, the password setting for ssh is included in the "ole/jessie64" box. Since I cannot find a good way to configure it in Vagrantfile, I decided to change the ssh password after the vm is set up and run using a script file.
It looks like this:

#!/bin/bash


VM_ID=`vagrant global-status | grep community | cut -d' ' -f1`
KEYPATH=`vagrant ssh-config ${VM_ID} | grep "IdentityFile" | cut -d' ' -f4`
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

ssh -i ${KEYPATH} [email protected] -p 2222 'bash -s' < ${DIR}/command.sh 

This script ssh to the vm and run a local script to change the password.

The local script is like this.

#!/bin/bash

echo -e "<currentpassword>\n<newpassword>\n<newpassword>" | passwd vagrant

Since I changed the password after the vm is set tup, this solution will be system dependent.

from ole--vagrant-community.

dogi avatar dogi commented on July 2, 2024

@xinglunxu awesome :)

will use this script for the ole template creation ... https://atlas.hashicorp.com/ole/boxes/jessie64
so that later we can just use the easy way of changing the password

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

Ok, I will modify it a little bit more later. Now it assume that the vagrant is using port 2222 for ssh. I should get it from the "vagrant ssh-config" command instead. Also, it is assuming that the name of the vm is "community". I should make it an argument for the script.

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

As promised, here is the improved version of the script
The comments inside the script already describe the behavior of it in detail

#!/bin/bash

#Run this script with the machine name to which you want to change the password. 
#Run it with "community" for development environment and "ole" for production environment
#Example: "sh changepassword.sh community"  

#parse the name of the vm machine from command line argument
VM_NAME=$1

VM_ID=`vagrant global-status | grep ${VM_NAME} | cut -d' ' -f1`
KEYPATH=`vagrant ssh-config ${VM_ID} | grep "IdentityFile" | cut -d' ' -f4`
PORT=`vagrant ssh-config ${VM_ID} | grep "Port" | cut -d' ' -f4`

#connect to vm and change password from "vagrant" to "openlearning"  replace "openlearning" with your customized password
ssh -i ${KEYPATH} [email protected] -p ${PORT} "echo -e \"vagrant\nopenlearning\nopenlearning\" | passwd vagrant"

I combined the previous two scripts into one. Also the the script now take the name of target vm as command line argument. The port number is also no longer hardcoded. It is parsed from "vagrant ssh-config".

Also, @dogi I remember you mentioned something about the vagrant box template in the hangout today. I couldn't hear you clearly so can you write it down here? Thanks!

BTW, it will be good if @EmilyLarkin or some other mac user friends can test it.

The testing process is as easy as following

  1. Run your "community" vagrant machine.
  2. ssh to the "community" machine with the password "vagrant". Make sure it works then exit
    the machine.
  3. Run the script like this
    sh changepassword.sh community
    You can just copy and paste the code above then run it from any directory.
  4. ssh to the "community" machine with the new password "openlearning". See if it works again.
    If successfully connect to vm again, then this script works.

To manually ssh to the "community" machine using a password, type the following command
ssh [email protected] -p 2222 then type the current password when prompt.
Please comment here or gitter if something go wrong or if there is any question. Thanks!

from ole--vagrant-community.

sente avatar sente commented on July 2, 2024

Is there a fork or branch of the entire repo? I have a mac and I'd like to give it a shot.

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

@sente Hi, I haven't make a pull request yet, but I think you can just copy and paste the code into any directory and run it as in the post. It is designed to run in any directory.

from ole--vagrant-community.

sente avatar sente commented on July 2, 2024

I don't currently use vagrant/docker on my mac so I'd be running the whole shebang from start to finish. It's good practice to use forks/branches anyways, in my opinion.

from ole--vagrant-community.

xinglunxu avatar xinglunxu commented on July 2, 2024

@sente This is my own fork of the ole--vagrant--community
https://github.com/xinglunxu/ole--vagrant-community
And I just pushed the changepassword.sh script to it. It is under the macosx directory.
There is only one branch there.
Is this something you are looking for?

from ole--vagrant-community.

dogi avatar dogi commented on July 2, 2024

done with update -defdf1d
which updates to version 0.1.4 of ole/jessie64

the change happens in treehouses/template@dd489c3

from ole--vagrant-community.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.