[Vagrant & VirtualBox] Vagrant 仮想マシンに接続するための ssh config 設定の方法

パスワードなしで rsync したいので調べました。

[markdown]
が、以前にも調べていました。。。

> * [vagrant ssh-config – Command-Line Interface – Vagrant Documentation](https://docs.vagrantup.com/v2/cli/ssh_config.html)
> * [Vagrant: + VirtualBox で仮想マシンを作成する | deadwood](https://www.d-wood.com/blog/2013/09/20_4688.html#vagrant_ssh-config)

`vagrant ssh-config` で下記のような出力が得られるので、

“`prettyprinted
% vagrant ssh-config
Host default
HostName 127.0.0.1
User vagrant
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/****/.vagrant.d/insecure_private_key
IdentitiesOnly yes
LogLevel FATAL
“`

`~/.ssh/config` に書き込んでしまいます。

“`prettyprinted
% vagrant ssh-config >> ~/.ssh/config
“`

`–host foo` オプションで、ホスト名を付けられます。

> * [ssh: 鍵作成とconfigによる複数ホストの管理 | deadwood](https://www.d-wood.com/blog/2013/05/17_3620.html)

こんな形でログインできました。

“`prettyprinted
% ssh default
Last login: Wed Aug 20 08:04:20 2014 from 10.0.2.2
[vagrant@wordpress ~]$ exit
logout
Connection to 127.0.0.1 closed.
“`
[/markdown]