我正在尝试使用 net/sftp gem 从 Heroku 的 SFTP To Go 下载文件,但我总是得到未定义的方法 `e=' for #.
一直在网上搜索,但找不到任何相关的解决方案。这是我的代码:
task employer_email_import: :environment do
require 'net/sftp'
require 'uri'
sftptogo_url = ENV['SFTPTOGO_URL']
uri = URI.parse(sftptogo_url)
Net::SFTP.start(uri.host, uri.user, :password => uri.password) do |sftp|
sftp.download!("some_directory", "some_directory")
end
end
错误: #< OpenSSL::PKey::RSA:0x00563aaff72138> 的未定义方法 `e=' 您的意思是?e**********
“/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/buffer.rb:255:in read_keyblob'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/buffer.rb:239:in
read_key' ", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:145:in block (2 levels) in keys_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:127:in
each_line'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:127 :in block in keys_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:125:in
open'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb :125:in keys_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:55:in
block in search_in'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh /known_hosts.rb:55:in map'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/known_hosts.rb:55:in
search_in'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net /ssh/known_hosts.rb:49:insearch_for'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:96:in
host_keys'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/algorithms.rb :251:in prepare_preferred_algorithms!'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/algorithms.rb:124:in
initialize'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport /session.rb:86:in new'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh/transport/session.rb:86:in
initialize'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net /ssh.rb:232:in new'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-ssh-3.2.0/lib/net/ssh.rb:232:in
start'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/net-sftp-2.1.2/lib/net /sftp.rb:31:in start'", "/home/romz/Desktop/Romz/site/ROR/recoverysuite/lib/tasks/scheduler.rake:376:in
block (2 levels) in '", "/home/romz/Desktop/Romz/site/ROR/recoverysuite/lib/tasks/scheduler.rake:353:in each'", "/home/romz/Desktop/Romz/site/ROR/recoverysuite/lib/tasks/scheduler.rake:353:in
block in '", " /home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:248:inblock in execute'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:243:in
每个'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:243:inexecute'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:187:in
块invoke_with_call_chain'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/2.4.0/monitor.rb:214:in mon_synchronize'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:180:in
invoke_with_call_chain'", "/home/romz/.rbenv/versions/2.4 .0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/task.rb:173:in invoke'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:152:in
invoke_task'", "/home/romz/.rbenv/versions/2.4.0 /lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:108:in block (2 levels) in top_level'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:108:in
each'", "/home/romz/.rbenv/versions/2.4.0/lib /ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:108:in block in top_level'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:117:in
run_with_threads'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby /gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:102:intop_level'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:80:in
阻止运行'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:178:instandard_exception_handling'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/lib/rake/application.rb:77:in
运行'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/rake-11.3.0/exe/rake:27:in <top (required)>'", "/home/romz/.rbenv/versions/2.4.0/bin/rake:23:in
load'", "/ home/romz/.rbenv/versions/2.4.0/bin/rake:23:in <top (required)>'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:74:in
load'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems /bundler-2.0.1/lib/bundler/cli/exec.rb:74:in kernel_load'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/cli/exec.rb:28:in
run'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems /bundler-2.0.1/lib/bundler/cli.rb:463:in exec'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in
run'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler -2.0.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in invoke_command'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor.rb:387:in
dispatch'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4 .0/gems/bundler-2.0.1/lib/bundler/cli.rb:27:indispatch'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in
开始'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/cli.rb:18:instart'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/exe/bundle:30:in
块'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/lib/bundler/friendly_errors.rb:124:in with_friendly_errors'", "/home/romz/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/bundler-2.0.1/exe/bundle:22:in
'", “/home/romz/.rbenv/versions/2.4.0/bin/bundle:23:in load'", "/home/romz/.rbenv/versions/2.4.0/bin/bundle:23:in
'”
RUBY_VERSION => "2.4.0"
OpenSSL::OPENSSL_VERSION => "OpenSSL 1.1.0g 2017 年 11 月 2 日"
OpenSSL::VERSION => "2.0.2"
rails --version => Rails 5.0.7.1