Learn how to securely route Ruby SFTP file transfers through a QuotaGuard Shield proxy using QGTunnel.
# QGTunnel
curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz
# SFTP Gem
gem install net-sftpQUOTAGUARDSHIELD_URL=... ./bin/qgtunnel ruby sftp.rbBe sure to set QUOTAGUARDSHIELD_URL to your Connection URL from the QuotaGuard Dashboard.
Additionally, to use the qgtunnel_config file, rename it as .qgtunnel to be discovered by bin/qgtunnel process
docker build -t qg-shield-ruby-sftp-example .
docker run -e QUOTAGUARDSHIELD_URL=... qg-shield-ruby-sftp-example
#!/usr/bin/env ruby
require 'net/sftp'
Net::SFTP.start('test.rebex.net', 'demo', password: 'password', port: 2222) do |sftp|
sftp.download!('readme.txt', 'readme.txt')
end
if File.exist?('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
#install qgtunnel
RUN curl https://s3.amazonaws.com/quotaguard/qgtunnel-latest.tar.gz | tar xz
ENV QGTUNNEL_DEBUG true
COPY sftp.rb sftp.rb
COPY qgtunnel_config .qgtunnel
ENTRYPOINT [ "bin/qgtunnel", "ruby", "sftp.rb" ]