go - 无法启动 shell: 无法启动 pty: fork/exec /usr/bin/sh: operation not allowed
问题描述
我正在尝试在本地环境的非 root 用户下安装和运行 AWS SSM 代理。例如,我将 amazon-ssm-agent 进程作为操作系统上的 ec2-user 启动。注册没有问题,我可以在 AWS SSM 控制台中看到 Ping 状态为“在线”。但是,当我尝试通过会话管理器对实例启动会话时,它总是失败并提示如下错误:
"Output": "\n----------ERROR-------\nUnable to start shell: Failed to start pty: fork/exec /usr/bin/sh: operation not permitted
相关的源代码片段是这样的:
func StartPty(
log log.T,
shellProps mgsContracts.ShellProperties,
isSessionLogger bool,
config agentContracts.Configuration,
plugin *ShellPlugin) (err error) {
log.Info("Starting pty")
//Start the command with a pty
var cmd *exec.Cmd
if strings.TrimSpace(shellProps.Linux.Commands) == "" || isSessionLogger {
cmd = exec.Command("sh")
} else {
commandArgs := append(utility.ShellPluginCommandArgs, shellProps.Linux.Commands)
cmd = exec.Command("date", commandArgs...)
}
....
ptyFile, err = pty.Start(cmd)
if err != nil {
log.Errorf("Failed to start pty: %s\n", err)
return fmt.Errorf("Failed to start pty: %s\n", err)
}
最初我虽然可能是该 shell 二进制文件的权限问题。但这并没有什么问题,每个人都可以运行 shell 命令。
有人知道这里发生了什么并对如何解决有任何建议吗?谢谢
顺便说一句,AWS SSM 代理源代码基于 Go 编程语言。
解决方案
推荐阅读
- c# - 如何从 RESTFul 请求中捕获客户端证书并在 C# 中针对服务器上的证书进行验证?
- javascript - 我尝试使用 .substring 获取 2 个数字或 1 个数字,但是当我使用 var price 时,只读取一个,为什么?
- node.js - 将 React Native 前端与无服务器 node.js 后端连接起来
- bash - 如何获得完整的路径,*允许*符号链接
- mongodb - 将主集合与事务状态集合匹配
- javascript - 语义 ui 滚动下拉列表不显示所选项目
- oracle - Oracle 历史报告 - 某个时间点的行是什么
- c++ - libswscale/swscale.h:没有这样的文件或目录
- r - 如何计算数据框中特定时间值的出现次数
- javascript - 寻找聪明的方式来重新设计这个和/或声明