How to ssh to vagrant without actually running “vagrant ssh”?

后端 未结 16 1584
清酒与你
清酒与你 2020-11-29 15:07

I would like to reproduce the way Vagrant logs in to my VM within a shell script using an ssh command, so I create an alias to my Vagrant instance.

What

16条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-29 15:26

    If you don't need to use stdin with ssh (for example you want to execute just a command and logout) you could use:

    vagrant ssh-config --host default | ssh -F /dev/stdin default
    

    This method was suggested in response to a similar question on google groups.

    Unfortunately bash process substitution doesn't work either (see this question on unix.stackexchange for more details).

    The best options you have, if you want an interactive shell, are to create a temp file and use that with ssh -F or use awk as suggested by the other answers.

提交回复
热议问题