Sunday, August 24, 2008

Ruby as a sysadmin tool: SFTP

My mission tonight - make Ruby SFTP file transfer work.[1]

require 'rubygems'
require 'net/sftp'

Net::SFTP.start('', 'userid', :password => 'deprecated') do |sftp|
sftp.upload!("/local/directory/output", "/remote/directory/")

52 kb of data - copied like that (snap): admirably fast.  Some minor problems to work out.

  • Authentication bits in plain text make me itch.  I need to encrypt those values.  This should not be a problem in 2008.  This is not a show stopper on my local disk [2] but it needs to happen for a server.
  • Error detection.
  • The sample above fails if the remote directory exists.

[1] For not good reason except that it's fun .. and I think that Ruby should make an adequate system administration tool. Stuff like this is important if you're going to use it that way.
[2] It should be a problem. Unencrypted anything in 2008 is ungood.
blog comments powered by Disqus