0

When I'm trying to Net::SSH.start to my debian ssh server and transfer a files, every time I've a very strange error message - `start': Net::SSH::AuthenticationFailed, but all the authentication data are correct, I don't know what a problem is. Does anyone faced same problem? The code was written on ruby and net/ssh module are in use, here is a code:

require 'rubygems'
require 'net/ssh'

def copy_file(session, source_path, destination_path=nil)
  destination_path ||= source_path
  cmd = %{cat > "#{destination_path.gsub('"', '\"')}"}
  session.process.popen3(cmd) do |i, o, e|
    puts "Copying #{source_path} to #{destination_path}... "
    open(source_path) { |f| i.write(f.read) }
    puts 'Done.'
  end
end

Net::SSH.start("192.168.112.129", 
                :username=>'username',
                :password=>'password') do |session|
  copy_file(session, 'D:/test/1.txt')
  copy_file(session, '/home/timur/Documents/new_file.rb"')
end
Hu Man
  • 71
  • 1
  • 1
  • 7

1 Answers1

0

There is no :username option in net/ssh 2.6, you can set it like parameter:

Net::SSH.start('192.168.112.129', 'username', password: 'password') do |ssh|
  foo
end
slowpoke
  • 143
  • 1
  • 9