2

It should be a simple question.

I had a vagrant box there, where I can start vagrant ssh to access it without password.

And how can I remotely execute ssh command to get some result like below, which can be used in jenkins CI server to check something.

$ vagrant ssh 'who -a' 

My environment

  • Vagrant 0.8.7
  • Ubuntu 11.04 (host)

3 Answers 3

1

The following should work; for more information check out man vagrant, man ssh and man who.

vagrant ssh -c "who -a"
0

You could also use the following to see the ssh config behind the vagrant ssh command:

vagrant ssh-config

Note: This will only work once you did vagrant up.

Then use the ip, port, key, etc. in your own ssh command:

ssh -i /path/to/vagrant/keyfile vagrant@ip:port who -a
0

To execute complex commands in Jenkins i prefer the following syntax

vagrant ssh -- who -a

where everything after the '--' is passed as a command to the VM's shell.

From http://docs.vagrantup.com/v2/cli/ssh.html:

If a -- (two hyphens) are found on the command line, any arguments after this are passed directly into the ssh executable.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .