Search code examples
rubynet-sftp

Trying to Net::SFTP download but get Errno::EACCES: Permission denied - Directory I'm copying to


I'm trying to copy a file from a Unix box to my local desktop but I'm getting the error: Errno::EACCES: Permission denied - C:\Users\MyUser\Desktop

require 'net/sftp'
Net::SFTP.start(unixBox, user, :password => password) do |sftp|
  sftp.download!(filePathOnUnixBox, 'C:\Users\MyUser\Desktop')
end

My Desktop: Windows 7

ruby 1.8.7 (2010-12-23 patchlevel 330) [i386-mingw32]

net-sftp (2.1.1)

Unix box: SunOS

UPDATE: Looks like you have to specify the filename in your TO file path so C:\Users\MyUser\Desktop becomes C:\Users\MyUser\Desktop\fileNameIWant.ext


Solution

  • Looks like you have to specify the filename in your TO file path so C:\Users\MyUser\Desktop becomes C:\Users\MyUser\Desktop\fileNameIWant.ext

    Before I was only specifying the path but not the file name.