amazon-web-services - 无法访问 tmp 目录中的文件
问题描述
我正在尝试使用 ebconfig 访问已下载到 /tmp/ 目录的.json 文件,以在 S3 上存储私钥。
files:
"/tmp/firebaseadminsdk.json" :
mode: "000400"
owner: root
group: root
authentication: "S3Auth"
source: 'source url'
但它给了我以下错误
Error: EACCES: permission denied, open '/tmp/firebaseadminsdk.json'
文档中有一段说
The second entry uses the S3Auth authentication method to download the private key from the specified URL and save it to /etc/pki/tls/certs/server.key. The proxy server can then read the private key from this location to terminate HTTPS connections at the instance.
不幸的是,我没有使用任何代理,因为建议不要使用,如果我将其更改为 ,它会导致实例的运行状况变得严重。
我再次确认 IAM 帐户对包含该文件的存储桶具有读写访问权限。我还添加了一个存储桶策略,以授予 IAM 帐户与存储桶交互的完全访问权限,如下所示
{
"Version": "2012-10-17",
"Id": "Policy1546355608026",
"Statement": [
{
"Sid": "Stmt_____",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::______:role/aws-elasticbeanstalk-ec2-role"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::_____/firebaseadminsdk.json"
}
]
}
我还将 ec2 转到我的实例中,并将 S3fullaccess 策略添加到实例正在使用的 IAM 角色中,但在完成所有这些操作之后,错误仍然存在。
我也在使用负载均衡器,这可能会导致一些问题?
错误信息
Error: EACCES: permission denied, open '/tmp/firebaseadminsdk.json'
at Object.openSync (fs.js:436:3)
at Object.readFileSync (fs.js:341:35)
at Object.Module._extensions..json (internal/modules/cjs/loader.js:705:20)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/var/app/current/index.js:9:22)
at Module._compile (internal/modules/cjs/loader.js:688:30)
fs.js:115
throw err;
解决方案
在您的文件复制代码中,从所有者读取更改权限400到为所有人读取444。
files:
"/tmp/firebaseadminsdk.json" :
mode: "000444"
owner: root
group: root
authentication: "S3Auth"
source: 'source url'
所有人的私钥读取权限可能不安全。
但我将它用于应用程序的 alpha 版本,稍后也会因为密钥轮换而实施 AWS KMS(密钥管理服务)。
推荐阅读
- scala - 如何编辑行值中的符号
- linux - pppd(点对点协议)在我的自定义嵌入式 linux 上不起作用
- php - 在 Ubuntu 上安装 mysqlnd_memcache 以预装 innodb_memcache 插件
- python - 为什么“Python 3.8 中的新增功能”中的“海象运算符”示例使用显式比较?
- mysql - 在 Cloud Mysql 中更新 PDF 文件
- github - 使用 terraform 在特定目录中克隆 github 存储库
- ssh - 打开网络,无法连接到我的设备(两台linux笔记本电脑和Android智能手机,),最好是SHH
- wordpress - Wordpress 网站中字体加载速度慢
- javascript - 如何使用 javascript for-loop 和 if-statement 在右表中显示数据?
- python - 数据分页时访问 Django-admin 页面上的页码