Last active
December 12, 2015 03:58
-
-
Save aubricus/4711167 to your computer and use it in GitHub Desktop.
Windows, Vagrant ssh snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:: Windows / Vagrant ssh snippet | |
:: Gotcha: Calling "ssh" from the windows CMD.exe requires Cygwin installed and | |
:: added to the PATH. This allows me to use the ssh port, but does not | |
:: require that I run this batch through Cygwin. | |
:: Notes: | |
:: The Vagrant convenience "vagrant ssh" doesn't work on windows. | |
:: One is left to manually ssh into the virtual box, which can be cumbersome. | |
:: Additionally, always connecting using "localhost" as the host will result in a | |
:: "WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED" error. | |
:: see: http://www.cyberciti.biz/faq/warning-remote-host-identification-has-changed-error-and-solution/ | |
:: To solve that problem and avoid clearing out ssh keys and / or deleting | |
:: the "known_hosts" file, I find it convenient to add an entry to | |
:: my "hosts" file; e.g., "127.0.0.1 my-site.ssh". | |
:: Note the convention of adding a ".ssh" to the host entry. | |
:: I'm usually in the hosts file to add an "127.0.0.1 my-site.dev" | |
:: entry so the effort amounts to a simple copy / paste / edit. | |
:: Command | |
:: ssh vagrant@HOST.ssh -p[PORT] | |
:: Parameters | |
:: HOST | |
::required | |
:: entry in your host file preceding the ".", e.g. [my-site].ssh | |
:: PORT | |
:: optional | |
:: defaults to 2222 | |
:: the ssh port you wish to use | |
:: Example, Basic | |
:: C:\>vagrant-ssh my-site | |
:: Example, with PORT configured | |
:: C:\>vagrant-ssh my-site 1234 | |
:: ProTip | |
:: Add the location of this script to your PATH to call it from any directory. | |
@ECHO OFF | |
SET HOST=%1 | |
SET PORT=%2 | |
IF [%2]==[] SET PORT=2222 | |
ssh vagrant@%HOST%.ssh -p%PORT% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment