Capistrano 3丢弃:执行远程SSH命令时的用户变量

 mobiledu2502852625 发布于 2023-02-12 10:51

试图从头开始测试Capistrano.

Capfile:

require 'capistrano/setup'
require 'capistrano/deploy'
I18n.enforce_available_locales = false
Dir.glob('lib/capistrano/tasks/*.rb').each { |r| import r }

deploy.rb:

role :testrole, 'x.x.x.x'
set :user, 'ubuntu'

test.rb任务:

namespace :test do
desc "Uptime on servers"
task :uptime do
  on roles(:testrole) do
    execute "uptime" 
  end
end
 end

cap命令:

cap production test:uptime

输出:

INFO [c077da7f] Running /usr/bin/env uptime on x.x.x.x
DEBUG [c077da7f] Command: /usr/bin/env uptime
cap aborted!
Net::SSH::AuthenticationFailed

使用相同的用户和密钥从shell登录时没有问题.登录远程服务器后,我可以在auth.log中看到执行上限时给出的空用户:

test-srv sshd[1459]: Invalid user  from x.x.x.x

我错过了什么?谢谢!

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有