首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Net::SSH工作于production控制台,AuthenticationFailed来自production

Net::SSH工作于production控制台,AuthenticationFailed来自production
EN

Stack Overflow用户
提问于 2011-09-23 18:14:42
回答 1查看 920关注 0票数 2

我有一个rails应用程序,用户可以提交表单并通过ssh连接到远程服务器来调用脚本。最终,我计划使用delayed_job或类似的东西,但即使是简单的测试,我也无法使它在生产中工作。

奇怪的是,Net::SSH在生产中从控制台运行得很好,但是当我在生产中提交表单时,它在AuthenticationFailed中失败了。在开发过程中,控制台和webapp都工作得很好。

错误:

网::SSH::AuthenticationFailed (my_ssh_username):

app/models/Branch.rb:69:在ssh\_to\_machine' app/controllers/branches\_controller.rb:55:in更新中

控制器的更新操作:

代码语言:javascript
复制
  def update
    @branch = Branch.find(params[:id])
    if @branch.update_attributes(params[:branch])
      @branch.ssh_to_machine(@branch.hostname, @branch.user_name, @branch.command_to_run)
      redirect_to @branch, :notice  => "Update request now processing."
    else
      render :action => 'edit'
    end
  end

方法,主要是从Net::SSH示例复制/粘贴:

代码语言:javascript
复制
def ssh_to_machine(host_name, user_name, command_to_run)
    require 'net/ssh'
    Net::SSH.start(host_name, user_name, { :verbose => Logger::DEBUG, :keys => %w{ /home/www-data/.ssh/my_ssh_username_id_rsa }, :auth_methods => %w{ publickey } }) do |ssh|
      # capture all stderr and stdout output from a remote process
      output = ssh.exec!("hostname")

      # run multiple processes in parallel to completion
      ssh.exec command_to_run
      ssh.loop
    end
end

我已经尝试过使用和不使用:详细、键、:auth_methods;每次都要小心地重新启动apache,但是在生产过程中,它总是从控制台运行(在调用'rails c‘之前导出RAILS_ENV=production ),而从不在webapp中工作。

当我从webapp调用它时,我也会欢迎任何关于如何增强日志记录的建议- :verbose在控制台为我工作,但没有为我的production.log添加任何东西。

EN

回答 1

Stack Overflow用户

发布于 2012-05-17 03:12:40

当您从控制台运行它时,您使用的是您自己的帐户,对吗?

这有点奇怪,但我的猜测是,您的生产web应用程序是在一个帐户下运行的,它没有读取"/home/www-data/.ssh/ my _ssh_username_id_rsa“的访问权限。

根据您的描述,它几乎必须是某种类型的权限问题。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7533170

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档