Running remote commands after vagrant ssh

2020-02-08 07:38发布

vagrant ssh -- EXTRA SSH ARGS is supposed to allow extra args to be passed to ssh.

vagrant ssh -- -t 'cd /var/www' should ssh into vagrant and change directory to /var/www, but doesn't. Instead it returns

ssh: Could not resolve hostname ls: nodename nor servname provided, or not known

What am I missing?

标签: ssh vagrant
2条回答
家丑人穷心不美
2楼-- · 2020-02-08 08:13

To run a command to a vagrant box remotelly run:

vagrant ssh -c "COMMAND; COMMAND1"

If you need, try vagrant ssh --help

查看更多
别忘想泡老子
3楼-- · 2020-02-08 08:21

This works for me:

vagrant ssh -- -t 'cd /var/www; /bin/bash'
查看更多
登录 后发表回答