Capistrano:shell 示例

发布于 2024-08-07 16:39:54 字数 224 浏览 3 评论 0原文

我目前正在使用 Capistrano 来部署我的 Web 应用程序,它的工作方式非常出色。

在我的新项目中,我必须从 sudo /bin/bash shell 执行命令。

Capistrano 是否可以以用户 X 身份登录机器,运行 sudo /bin/bash, 输入密码然后在 sudo shell 中执行命令?如果是的话,你可以吗 请给我举个例子。

关于

雅各布

I'm currently using Capistrano to deploy my web application which works like a charm.

In my new project I must execute a command from sudo /bin/bash shell.

Is it possible for Capistrano to login to the machine as user X, run sudo /bin/bash,
enter the password and then execute a command in the sudo shell? If yes, could you
please provived me with an example.

With regards

jakob

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千寻… 2024-08-14 16:39:54

您需要进入 root shell 而不是使用 sudo 执行命令有什么具体原因吗?如果使用 sudo 执行命令,您只需 sudo 'command' 而不是 run 'command'

我做了一些实验,尝试使用 capistrano 获得 root shell,而无需直接以 root 身份登录服务器,但未能取得太大进展。

如果使用 sudo 运行不起作用,请更新您的问题,让我们知道原因,也许我们可以帮助您找到解决方法。

更新:

多玩一会儿后,我发现您可以通过执行类似 sudo '/bin/bash -c 的操作在 root shell 中执行单个命令(或命令字符串) “whoami”'。获得一个交互式 root shell 是很棘手的。

Is there a specific reason you need to be in a root shell rather than executing the command with sudo? If executing a command with sudo, you can simply sudo 'command' instead of run 'command'.

I did a little experimentation to try to get a root shell with capistrano without logging into the server directly as root, and wasn't able to make much progress.

If running with sudo won't work, please update your question to let us know why and maybe we can help you find a workaround for it.

Update:

After playing around a little more, I found that you can execute an individual command (or string of commands) in a root shell by doing something like sudo '/bin/bash -c "whoami"'. It's getting an interactive root shell that's tricky.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文