» SSH
This will SSH into a running Vagrant machine and give you access to a shell.
On a simple vagrant project, the instance created will be named default.
Vagrant will ssh into this instance without the instance name:
Or you could use the name:
On a system with machines running from different projects, you could use the idas listed in vagrant global-status
If a —
(two hyphens) are found on the command line, any arguments afterthis are passed directly into the executable. This allows you to passany arbitrary commands to do things such as reverse tunneling down into thessh
program.
-c COMMAND
or—command COMMAND
- This executes a single SSH command, printsout the stdout and stderr, and exits.
For Windows installations, an SSH client is provided within the installerimage. If no SSH client is found on the current PATH, Vagrant will use theSSH client it provided. Depending on the local environment used for runningVagrant, the installer provided SSH client may not work correctly. For example,when using a cygwin or msys2 shell the SSH client will fail to work as expectedwhen run interactively. Installing the SSH package built for the current workingenvironment will resolve this issue.
If the command you specify runs in the background (such as appending a &
toa shell command), it will be terminated almost immediately. This is becausewhen Vagrant executes the command, it executes it within the context of ashell, and when the shell exits, all of the child processes also exit.
To avoid this, you will need to detach the process from the shell. PleaseGoogle to learn how to do this for your shell. One method of doing this isthe nohup
command.
The SSH executable will not be able to access Pageant on Windows. WhileVagrant is capable of accessing Pageant via internal libraries, theSSH executable does not have support for Pageant. This means keysfrom Pageant will not be available for forwarding when using the command.