search
LoginSignup
30
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

updated at

vagrant 1.7以降は'vagrant up'した時にinsecure_keyを差し替える

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

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
What you can do with signing up
30
Help us understand the problem. What are the problem?