How to Read SFTP files in Ruby
Using net-sftp gem to read remote files in ruby
3 min readJan 23, 2023
Originally Published in https://asyncq.com/
Introduction
- SFTP is very common way to transfer the file from one server to another.
- Often as a client we recieve SFTP server endpoint to pull the file to our system from other system.
- In this article we will use ruby client to read the remote file which is located on SFTP server.
Note: We are using username and password in this article, but in future article we will use public , private key pair to connect.
SFTP Server
- If you dont have SFTP server then you can setup one on local system or Cloud environment for test purpose.
- I have setup one for my use case on GCP. My Linux environment is based on Ubuntu and I followed this guide to setup SFTP server.
Business Logic
Library
- We will use a popular ruby gem called ‘net-sftp’ to connect to SFTP server.
- get it using gem install