Unable to create file with correct permissions using Net::SSH library
I'm having troubles correctly setting file permissions using the Net::SSH library. Although I can correctly set the file's permissions after creating it, I need the file to have the correct permissions in the instance it's created. I'm connecting to an Ubuntu machine, and the ssh user has full permissions in the开发者_如何学编程 directory.
Here's a simplified version of the code illustrating where it's failing.
Net::SFTP.start('servername', 'username', :password => 'password') do |sftp|
file_handle = sftp.open!('/remote/file/path', 'w', :permissions => 0777)
# file has permissions 0755, but should have 0777
sftp.fsetstat!(file_handle, {:permissions => 0777})
# file now has correct 0777 permissions
...
end
精彩评论