0

Using vagrant ssh I'm able to ssh into VM(ubuntu). But once I ssh into VM, I want to go to a directory on VM's Desktop and execute a command. In short, I want to achieve the following:

a) ssh into VM

b) Go to a directory on VM's Desktop

c) Execute a command (for eg. list all the hidden files in this directory/install a software in this directory)

I tried using vagrant ssh -c "cd /Desktop".

This gives me a message:-- Connection to 127.0.0.1 closed.

Is there any way I can go to folder and execute command using vagrant ssh?

2 Answers 2

0

This is normal. The cd command is not giving any output. If you would do for example vagrant ssh -c "ls" you would get the directory content, and afterwards the Connection closed message.

So vagrant ssh -c "..." is the way to go!

0
vagrant ssh -c 'cd /Directory && <my cmd here>'

You must log in to answer this question.

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