Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

It should a simple question.

I had a vagrant box there, where I can start vagrant ssh to access 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)
share|improve this question

migrated from Oct 20 '11 at 11:05

This question came from our site for professional and enthusiast programmers.

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

vagrant ssh -c "who -a"
share|improve this answer

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
share|improve this answer

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.


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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.