Module: VagrantPlugins::RekeySSH::Helpers
- Included in:
- ActionSSHInfo, ActionSecureBox
- Defined in:
- lib/vagrant-rekey-ssh/helpers.rb
Instance Method Summary collapse
- #generate_ssh_key ⇒ Object
- #rekey_sentinel_file ⇒ Object
- #ssh_key_path ⇒ Object
- #ssh_pubkey_path ⇒ Object
- #ssh_public_key ⇒ Object
Instance Method Details
#generate_ssh_key ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vagrant-rekey-ssh/helpers.rb', line 8 def generate_ssh_key unless ::File.exists?(ssh_key_path) @machine.ui.info(I18n.t("vagrant_rekey_ssh.info.generating_key")) key = SSHKey.generate(:comment => "vagrant less insecure private key") begin File.write(ssh_key_path, key.private_key) # Fix ssh key permissions on Unix systems File.chmod(600, ssh_key_path) if (/cygwin|mswin|mingw|bccwin|wince|emx/ =~ RUBY_PLATFORM) == nil File.write(ssh_pubkey_path, key.ssh_public_key) rescue => exc raise Errors::ErrorCreatingSshKey, error_message: exc. end @machine.ui.info(I18n.t("vagrant_rekey_ssh.info.key_generated", :path => ssh_key_path)) end end |
#rekey_sentinel_file ⇒ Object
28 29 30 |
# File 'lib/vagrant-rekey-ssh/helpers.rb', line 28 def rekey_sentinel_file ::File.join(@machine.data_dir, "rekey_sentinel") end |
#ssh_key_path ⇒ Object
36 37 38 |
# File 'lib/vagrant-rekey-ssh/helpers.rb', line 36 def ssh_key_path ::File.join(@env[:home_path], "less_insecure_private_key") end |
#ssh_pubkey_path ⇒ Object
40 41 42 |
# File 'lib/vagrant-rekey-ssh/helpers.rb', line 40 def ssh_pubkey_path ::File.join(@env[:home_path], "less_insecure_private_key.pub") end |
#ssh_public_key ⇒ Object
32 33 34 |
# File 'lib/vagrant-rekey-ssh/helpers.rb', line 32 def ssh_public_key IO.read(ssh_pubkey_path).scan( /^(\S+\s+\S+).*$/ ).last.first end |