Why does vagrant ssh -c ... not run the command?

43 views
Skip to first unread message

Brandon Sussman

unread,
Sep 1, 2017, 10:43:23 AM9/1/17
to Vagrant
vagrant ssh

works - connects me as user vagrant

vagrant ssh -c ls

does the exact same thing - connects me as user vagrant, does not execute the command.

Why?

Verbatim from doc: This should 'execute a single SSH command, prints out the stdout and stderr, and exit'.

Alvaro Miranda Aguilera

unread,
Sep 4, 2017, 12:53:29 AM9/4/17
to vagra...@googlegroups.com
vagrant ssh -c 'ls -al'

Alvaro

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/1d3aa196-5458-4482-962f-ca3750be3d83%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Brandon Sussman

unread,
Sep 4, 2017, 7:11:59 AM9/4/17
to Vagrant
1. It would be unusual for quotes to be required whan a parm value is a single word.
2. here is the console output showing the ssh logging in instead of doing what  the doc says it should and the command manually entered with it's output, followed by the standard logout, being ctl-d:

Besides, I do not want ls -al, I want ls.

> vagrant ssh -c 'ls -al'

vagrant@www
:~$ ls  -al
total
40
drwxr
-xr-x 4 vagrant vagrant 4096 Sep  4 11:03 .
drwxr
-xr-x 4 root    root    4096 Sep  3 17:26 ..
-rw------- 1 vagrant vagrant  111 Sep  4 11:06 .bash_history
-rw-r--r-- 1 vagrant vagrant  220 Jan 15  2017 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3486 Jan 15  2017 .bashrc
drwx
------ 2 vagrant vagrant 4096 Jan 15  2017 .cache
-rw-r--r-- 1 vagrant vagrant  773 Jan 15  2017 .profile
-rw-rw-r-- 1 vagrant vagrant   17 Jan 15  2017 shutdown.sh
drwx
------ 2 vagrant root    4096 Sep  3 17:25 .ssh
-rw-r--r-- 1 vagrant vagrant    6 Jan 15  2017 .vbox_version
vagrant@www
:~$ exit
Connection to 127.0.0.1 closed.
>



On Monday, September 4, 2017 at 12:53:29 AM UTC-4, Alvaro Miranda Aguilera wrote:
vagrant ssh -c 'ls -al'

Alvaro
On Fri, Sep 1, 2017 at 4:43 PM, Brandon Sussman <webste...@gmail.com> wrote:
vagrant ssh

works - connects me as user vagrant

vagrant ssh -c ls

does the exact same thing - connects me as user vagrant, does not execute the command.

Why?

Verbatim from doc: This should 'execute a single SSH command, prints out the stdout and stderr, and exit'.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
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.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Sep 5, 2017, 2:44:02 AM9/5/17
to vagra...@googlegroups.com
Hello

vagrant ssh -c ls

does ls in the vm

the answer on why you didn't saw any output is probably because was no public files when you tried

'ls -al' is to show all the files and extended attributes

if you try now again it should list that shutdown.sh file at least

Alvaro

To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/74e2886b-7e7c-469c-823e-c42bf16e4211%40googlegroups.com.

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



--
Alvaro

Brandon Sussman

unread,
Sep 5, 2017, 8:56:45 AM9/5/17
to Vagrant

No - thanks for trying but please look at the console log I posted.

' ssh vagrant@vmaddress pwd' works fine.  'vagrant ssh --command pwd' does not.



--
Alvaro

Brandon Sussman

unread,
Sep 5, 2017, 9:09:23 AM9/5/17
to Vagrant
Interesting solution

'vagrant ssh -- pwd' works!

-- is used in unix to pass options to the program next 'down the line' which is the standard unix ssh on the host.

I do not understand why -c or --command does not work as documented but I don't want to spend today reading ruby :)
Reply all
Reply to author
Forward
0 new messages