Public/Private key authentication for Ruby Net::SFTP
问题 I am having trouble finding documentation for specifying a key for SFTP authentication. Would like to have something like: export SOME_PRIVATE_KEY="$(cat tmp/some-certs/privatekey.pem)" # then somewhere in the code private_key = OpenSSL::PKey::RSA.new(ENV['SOME_PRIVATE_KEY']) Net::SFTP.start(ftp_host, user, key: private_key) do |sftp| sftp.dir.entries('/path/to/folder').each do |remote_file| # ... end end 回答1: Net::SFTP.start passes its options hash directly to Net::SSH.start , so we should