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

查看:45
本文介绍了在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< password>|sudo -S systemctl重新启动<某些服务> .没有运气.

完成此操作的安全方法是什么?

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天全站免登陆