8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/vagrant-poderosa/shortcut.rb', line 8
def self.create_shortcut(vm, ssh_info)
ssh_login_parameters = {
'destination' => ssh_info[:host],
'port' => ssh_info[:port],
'account' => ssh_info[:username]
}
if ssh_info.include?(:password)
ssh_login_parameters['authentication'] = 'Password'
ssh_login_parameters['passphrase'] = ssh_info[:password]
elsif ssh_info.include?(:private_key_path)
ssh_login_parameters['authentication'] = 'PublicKey'
ssh_login_parameters['identityFileName'] =
absolute_winpath(ssh_info[:private_key_path][0], vm.env.root_path)
end
doc = REXML::Document.new
doc << REXML::XMLDecl.new('1.0', 'UTF-8')
root = doc.add_element('poderosa-shortcut', 'version' => '4.0')
root.add_element('Poderosa.Terminal.TerminalSettings',
'encoding' => 'UTF8', 'caption' => ssh_info[:host])
root.add_element('Poderosa.Protocols.SSHLoginParameter',
ssh_login_parameters)
filename = Pathname(Dir.tmpdir) + ('vagrant-' + vm.name.to_s + '.gts')
File.open(filename, 'wb') do |file|
doc.write file
file.close
end
filename
end
|