LoginSignup
1
1

More than 5 years have passed since last update.

vagrantで共有フォルダ設定が反映されなったときの対処メモ

Last updated at Posted at 2016-08-19

vagrant up したとき, Authentication failureと出ていたが, 立ち上がったので無視していたら共有フォルダが使えなかったので対処しました。

仮想環境内の公開鍵とvagrand upで生成されるホスト側の秘密鍵が合わないために生じたエラーらしいです。

以下のメモは, 適当に端折ったり, 書き換えたり, 個人の設定に依存したりしてますのでご了承を.

vagrant側で生成した秘密鍵を基に公開鍵を作成する。
$ cd /home/username/vagrantを使ってるフォルダ/.vagrant/machines/default/virtualbox/private_key
$ ssh-keygen -yf private_key > public_key
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Permissions 0755 for 'private_key' are too open.
It is required that your private key files are NOT accessible by others.
This private key will be ignored.
Load key "private_key": bad permissions
権限が甘すぎると起こられたので変更
$ chmod 0600 private_key
改めて公開鍵を生成
$ ssh-keygen -yf private_key > public_key
作った鍵をscpを使って仮想環境へ送信。
$ vagrant status
Current machine states:

default                   running (virtualbox)
$ vagrant ssh-config
Host default
  HostName x.x.x.x
  Port yyyy
$ scp -P yyyy public_key vagrant@x.x.x.x:/home/vagrant/
....
public_key                                            100%  381    11.3KB/s   00:00

vagrantに接続し、公開鍵を置き換える
$ vagrant ssh

[vagrant@localhost ~]$ mv public_key /home/vagrant/.ssh/authorized_keys
vagrantを再起動
$ vagrant reload

==> default: Mounting shared folders...
    default: 仮想環境内の共有フォルダパス => ホスト側の共有フォルダパス
ちゃんと共有フォルダが適用されました.

参考先:

http://tomy2002.hatenablog.com/entry/2016/04/06/005344
http://qiita.com/kobake@github/items/534297a1161fcccb06d6
http://blog.ruedap.com/2011/04/04/mac-ssh-key-copy-error
http://d.hatena.ne.jp/hidde/20090518/1242621452

1
1
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
1
1