在 Azure Devops SSH 任务中运行“sudo"命令的安全方式 [英] Secure way to run `sudo` commands in Azure Devops SSH Task

查看:35
本文介绍了在 Azure Devops SSH 任务中运行“sudo"命令的安全方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须通过 Azure Devops 发布管道在 Azure VM 中运行一些命令.我创建了 SSH 步骤并且可以成功连接到远程 VM.但是在运行需要 sudo 权限的命令时遇到问题.

I have to run few commands in Azure VM through Azure Devops release pipeline. I created SSH step and can successfully connect to remote VM. But having trouble running commands which requires sudo permissions.

例如 systemctl restart <某些服务>

errors :
##[error][sudo] password for ***: 
##[error]Command failed with errors on remote machine.

我试过 echo |sudo -S systemctl restart <某些服务>.没有运气.

实现此目的的安全方法是什么?

What is secure way to accomplish this?

推荐答案

我能够通过 ssh 任务运行 sudo 的唯一方法是让 sudoer 成为没有密码的 root 用户,因为您的代理可能会卡在 STDIN.这篇文章可能会有所帮助https://www.shellhacks.com/how-to-grant-root-access-user-root-privileges-linux/

The only way to I was able to run sudo over ssh task was to make the sudoer as root memeber with no password for me as your agent might stuck in STDIN. this article may help https://www.shellhacks.com/how-to-grant-root-access-user-root-privileges-linux/

这篇关于在 Azure Devops SSH 任务中运行“sudo"命令的安全方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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