フラミナル

考え方や調べたことを書き殴ります。IT技術系記事多め

【Cygwin】vagrant ssh実行時にログインできない問題を解消した

f:id:lirlia:20171010104500p:plain

Cygwin環境下でvagrantを使用してvagrant sshを実行した所、プロンプトが帰ってこない事象が発生した。

ちなみにvagrant reloadをすると以下のメッセージがたくさんでてきます。

$ warning: connection aborted. retrying vagrant
$ warning: connection reset. retrying vagrant

色々調べたがどこにも情報がなく、なんとか自力で解決できたので共有です

解決方法

vagrant ssh --debugを実行した所以下のログが出力された。

DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 0
DEBUG virtualbox_5_1:   - [1, "ssh", 2201, 22, "127.0.0.1"]
 INFO subprocess: Starting process: ["C:\\HashiCorp\\Vagrant\\embedded\\usr\\bin/ssh.EXE"]
DEBUG subprocess: Selecting on IO
DEBUG subprocess: stderr: usage: ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
           [-D [bind_address:]port] [-E log_file] [-e escape_char]
           [-F configfile] [-I pkcs11] [-i identity_file]
           [-J [user@]host[:port]] [-L address] [-l login_name] [-m mac_spec]
           [-O ctl_cmd] [-o option] [-p port] [-Q query_option] [-R address]
           [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]]
           [user@]hostname [command]
DEBUG subprocess: Waiting for process to exit. Remaining to timeout: 32000
DEBUG subprocess: Exit status: 255
 INFO ssh: Invoking SSH: ssh ["vagrant@127.0.0.1", "-p", "2201", "-o", "LogLevel=FATAL", "-o", "Compression=yes", "-o", "DSAAuthentication=yes", "-o", "IdentitiesOnly=yes", "-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null", "-i", "C:/Users/xxx/Desktop/doc/tec/vagrant/test_env/centos7.2_anything/.vagrant/machines/default/virtualbox/private_key"]

どうやらHashiCorpで用意しているsshコマンドがオプションエラーを起こしているらしい。

ということで、これを標準のsshといれ変えてみる。

手順

私はGitを入れていたのでsshが入っていたが、もし入っていない人は別途sshを入れてほしい。

$ which ssh
/usr/bin/ssh 

# パスは各自の環境に合わせてください
$ mv C:\HashiCorp\Vagrant\embedded\usr\bin\ssh.EXE C:\HashiCorp\Vagrant\embedded\usr\bin\ssh_vagrant.EXE 

$ ln -s /usr/bin/ssh C:\HashiCorp\Vagrant\embedded\usr\bin\

できた!!

# vagrant ssh
Last login: Thu Oct 12 08:58:04 2017 from 10.0.2.2
[vagrant@localhost ~]$