31
44

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

vagrantでログインする際のユーザーを変更する

Last updated at Posted at 2014-06-13

仮想マシンにログインする方法は2通りある。

1.vagrant ssh

デフォルトではvagrantユーザーでログインされる。この方法でユーザーを変えたい場合はVagrantfileに下記を追加。

config.ssh.guest_port = 22
config.ssh.username = "yusuke"
config.ssh.host = "127.0.0.1"
config.ssh.private_key_path = "/Users/higakiyuusuke/.ssh/id_rsa"

これでyusukeユーザーでログインできる。
Vagrantfileを編集したらvagrant reloadを忘れずに。

2.ssh melody

chef利用時にknifeコマンドを使う使う場合などは仮想サーバーに名前をつけてこちらでやるほうが便利。この方法でユーザーを変えたい場合は~/.ssh/configに下記を追加。

Host melody
HostName 127.0.0.1
User yusuke
Port 2222
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
PasswordAuthentication no
IdentityFile /Users/higakiyuusuke/.ssh/id_rsa
IdentitiesOnly yes 
LogLevel FATAL

両方とも鍵認証でログインする場合を想定しています。

31
44
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
31
44

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?