Learn how to route Ruby SFTP file transfers through a QuotaGuard Static IP proxy.
# SFTP Gem
gem install net-sftpQUOTAGUARDSTATIC_URL=... ruby sftp.rbBe sure to set QUOTAGUARDSTATIC_URL to your Connection URL from the QuotaGuard Dashboard.
docker build -t qg-static-ruby-sftp-example .
docker run -e QUOTAGUARDSTATIC_URL=... qg-static-ruby-sftp-example#!/usr/bin/env ruby
require 'net/ssh/proxy/http'
require 'net/sftp'
require 'uri'
quotaguard = URI.parse(ENV["QUOTAGUARDSTATIC_URL"])
proxy = Net::SSH::Proxy::HTTP.new(quotaguard.host, quotaguard.port, user: quotaguard.user, password: quotaguard.password)
Net::SFTP.start('test.rebex.net', 'demo', password: 'password', proxy: proxy) do |sftp|
sftp.download!('readme.txt', 'readme.txt')
end
if File.exists?('readme.txt')
puts "Downloaded 'readme.txt' successfully"
puts " CONTENTS"
puts "--------------"
puts File.read('readme.txt')
puts "--------------"
else
puts "MISSING 'readme.txt'"
exit 1
end
FROM ruby:latest
WORKDIR /app/
RUN gem install net-sftp
COPY sftp.rb sftp.rb
ENTRYPOINT [ "ruby", "sftp.rb" ]
Welcome,
You are connected to an FTP or SFTP server used for testing purposes by Rebex FTP/SSL or Rebex SFTP sample code.
Only read access is allowed and the FTP download speed is limited to 16KBps.
For information about Rebex FTP/SSL, Rebex SFTP and other Rebex .NET components, please visit our website at https://www.rebex.net/
For feedback and support, contact support@rebex.net
Thanks!