Skip to content

Commit

Permalink
'password' is not mandatory for SFTP
Browse files Browse the repository at this point in the history
It can use SSH public keys to login.
  • Loading branch information
vitaly committed Jul 5, 2009
1 parent c9086a5 commit 46edabe
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/astrails/safe/sftp.rb
Expand Up @@ -5,7 +5,7 @@ class Sftp < Sink
protected

def active?
host && user && password
host && user
end

def path
Expand All @@ -16,7 +16,9 @@ def save
puts "Uploading #{host}:#{full_path} via SFTP" if $_VERBOSE || $DRY_RUN

unless $DRY_RUN || $LOCAL
Net::SFTP.start(host, user, :password => password) do |sftp|
opts = {}
opts[:password] = password if password
Net::SFTP.start(host, user, opts) do |sftp|
puts "Sending #{@backup.path} to #{full_path}" if $_VERBOSE
begin
sftp.upload! @backup.path, full_path
Expand Down

0 comments on commit 46edabe

Please sign in to comment.