lib/kitchen/driver/vz.rb in kitchen-vz-0.1.3 vs lib/kitchen/driver/vz.rb in kitchen-vz-0.1.4

- old
+ new

@@ -29,10 +29,11 @@ class Vz < Kitchen::Driver::SSHBase default_config :socket, 'local' default_config :username, 'kitchen' default_config :private_key, File.join(Dir.pwd, '.kitchen', 'kitchen_id_rsa') default_config :public_key, File.join(Dir.pwd, '.kitchen', 'kitchen_id_rsa.pub') + default_config :use_agent_forwarding, false default_config :network, 'Bridged' => { dhcp: true } default_config :use_sudo, true default_config :arch, 'x86_64' default_config :customize, memory: '512M', disk: '10G', cpus: 2 default_config :ostemplate, nil @@ -133,11 +134,13 @@ execute_command("#{prlctl} start #{state[:ct_id]}") end def create_user(state) ["useradd #{config[:username]}", - "mkdir /home/#{config[:username]}/.ssh", + "mkdir -p /home/#{config[:username]}/.ssh", + "chown #{config[:username]}: /home/#{config[:username]}", + "chmod 700 /home/#{config[:username]}", "chown #{config[:username]}: /home/#{config[:username]}/.ssh", "chmod 700 /home/#{config[:username]}/.ssh", "echo '#{File.open(config[:public_key]).read}' > /home/#{config[:username]}/.ssh/authorized_keys", "chown #{config[:username]}: /home/#{config[:username]}/.ssh/authorized_keys", "chmod 600 /home/#{config[:username]}/.ssh/authorized_keys", @@ -204,10 +207,10 @@ raise "Invalid URI scheme: #{uri.scheme}. Only 'ssh' is supported." if uri.scheme != 'ssh' uri end def ssh_connection - @connection ||= Net::SSH.start(uri.host, uri.user, port: uri.port) + @connection ||= Net::SSH.start(uri.host, uri.user, port: uri.port, forward_agent: config[:use_agent_forwarding]) end end end end