net-ssh / net-sftp

Pure Ruby implementation of an SFTP (protocols 1-6) client.
http://net-ssh.github.io/
MIT License
286 stars 130 forks source link

Support connecting over a port other than 22 #143

Open warrenbhw opened 1 year ago

warrenbhw commented 1 year ago

In some rare cases, I want to make a connection over a custom port.

Druwerd commented 1 year ago

@warrenbhw I couldn't find it in the docs but it does support non-standard ports. This works for me:

sftp_options = {
      password: ENV['SFTP_PASSWORD'],
      port: ENV['SFTP_PORT'], # this is set to 8022
      non_interactive: true,
      append_all_supported_algorithms: true
}
sftp = Net::SFTP.start(ENV['SFTP_HOST'], ENV['SFTP_USER'], sftp_options)