31
30

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 1.7以降は'vagrant up'した時にinsecure_keyを差し替える

Last updated at Posted at 2014-12-18

vagrantをアップデートしたらゲストにログインできなくなって焦った。
原因はタイトルの通り。

ちゃんと見てなかったけどログにも出てた。

    default: Vagrant insecure key detected. Vagrant will automatically replace
    default: this with a newly generated keypair for better security.
    default:
    default: Inserting generated public key within guest...
    default: Removing insecure key from the guest if its present...
    default: Key inserted! Disconnecting and reconnecting using new SSH key...

この機能を無効化したい場合、Vagrantfileで以下を設定する

Vagrantfile
  config.ssh.insert_key = false

ゲストにログインする際に vagrant sshしない(主にWindowsな)人はご注意を。

※参照
https://twitter.com/mitchellh/status/525704126647128064

もう面倒だからRakeからTeraTerm呼び出すtask作った。

Rakefile
desc 'login with TeraTerm SSH'
task :ssh do
  host, port, user, keyfile = nil, nil, nil, nil
  `vagrant ssh-config`.each_line do |l|
    host = l.sub('HostName','').strip if l.strip.match(/^HostName\s/)
    port = l.sub('Port','').strip if l.strip.match(/^Port\s/)
    user = l.sub('User','').strip if l.strip.match(/^User\s/)
    keyfile = l.sub('IdentityFile','').strip if l.strip.match(/^IdentityFile\s/)
  end
  spawn({"PATH" => "C:\\Program Files\\teraterm"}, "ttermpro #{host}:#{port} /ssh /auth=publickey /user=#{user} /keyfile=#{keyfile}")
end
31
30
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
30

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?