Tuesday, 9 December 2008

sftp from behind firewall via HTTP proxy in Ruby

Same as the previous Post using ruby:
require 'rubygems'
require 'net/ssh'
require 'net/sftp'
require 'net/ssh/proxy/http'

base_dir = "/some_base_directory"

proxy_host = 'IP_or_FQDN_of_your_proxy'
proxy_port = port_of_your_proxy

proxy = Net::SSH::Proxy::HTTP.new(proxy_host,proxy_port)

Net::SSH.start('destination_IP_or_FQDN','username',
{:proxy => proxy,
:password => 'password'}) do |ssh|

ssh.sftp.connect do |sftp|
# do something
end
end

No comments: