Vagrantのhost-only設定がうまくいかない
Vagrantのhost-only設定で少し悩んでた。
config.vm.network :hostonly, "192.168.33.10"
どうやらこの書き方は古いらしく、こう書くのが正しいらしい。
config.vm.network :private_network, ip: "192.168.33.10"
sshの設定をconfigファイルに書き出し
$ vagrant ssh-config --host vagrantTest >> ~/.ssh/config
書き出したファイルはこんな感じ。
Host default HostName 127.0.0.1 User vagrant Port 2222 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /USER/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL
あれ、HostNameが192.168.33.10じゃない。 NATからポートフォワーディングで接続する設定になってるぽい。 なので、192.168.33.10でアクセスできるように設定を変える。
Host default HostName 192.168.33.10 User vagrant Port 22 UserKnownHostsFile /dev/null StrictHostKeyChecking no PasswordAuthentication no IdentityFile /USER/.vagrant.d/insecure_private_key IdentitiesOnly yes LogLevel FATAL
これで無事sshで接続できた。
参考
- http://blog.allianceport.jp/aptv/2013/07/vagrant-1.html
- http://www1205uf.sakura.ne.jp/wp/world/?tag=vagrant
- http://yudoufu.hatenablog.jp/entry/20100117/1263677767
- http://d.hatena.ne.jp/tanakakns/20140107/1389085227
- http://qiita.com/kidachi_/items/e63c1607705178aa257c
- http://blog.yoshikawa.64kb.net/2013/09/21/306