Capistrano 3须藤任务 [英] Capistrano 3 sudo task

查看:78
本文介绍了Capistrano 3须藤任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用Capistrano 3用sudo在远程服务器上执行任务来编写配方。

I want to write a recipe with Capistrano 3 executing a task on the remote server with sudo.

使用Capistrano 2可以做到这一点,例如:

With Capistrano 2 this could be done for example:

default_run_options[:pty] = true

task :hello do
  run "#{sudo} cp ~/something /something"
end

有了Capistrano 3,我发现:

With Capistrano 3 I found:

set :pty, true

但是我无法执行使用sudo运行的任务。

But I could not get to execute a task running with sudo.

如何使用sudo运行任务?

How can I run a task with sudo?

推荐答案

Capistrano 3指南建议使用无密码sudo。这样一来,权限较低的用户就可以执行sudo命令,而不必通过PTY输入密码。

The Capistrano 3 guide recommends the use of passwordless sudo. This allows your less-priveleged user execute the sudo command without having to enter a password via the PTY.

您可以使用Kentaro上面编写的任务,并添加类似内容将以下内容添加到/ etc / sudoers文件中:

You can use the task that Kentaro wrote above, and add something like the following to your /etc/sudoers file:

deploy ALL=NOPASSWD:/bin/cp ~/something /something

http://www.capistranorb.com/documentation/getting-started/authentication-and-authorisation/#toc_8

这篇关于Capistrano 3须藤任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆