简体   繁体   English

在Google Cloud功能中设置密钥

[英]Setting Secret Key in google cloud functions

I need to sftp into an amazon ec2 instance to send files from data farmed from a firestore data base. 我需要sftp到amazon ec2实例中,以从从firestore数据库中获取的数据中发送文件。 I'm trying to open the connection but I need to have access to the ec2 secret key file in the cloud functions. 我正在尝试打开连接,但需要访问云功能中的ec2密钥文件。

I've done slightly similar things such as with stripe and the secret key so I believe this should be possible. 我已经做过一些类似的事情,例如使用stripe和秘密密钥,所以我相信这应该是可能的。 How do I upload my secret key file so I can have access to in the function below? 如何上传我的密钥文件,以便可以访问下面的功能?

return sftp.connect({
    host: 'xxxxxxxxxxxx',
    port: 'xxxx',
    username: 'xxxxxx',
    privatekey: 'filepath'
    })

I simply put the secret key in the main directory and read it into the environment with 我只是将密钥放在主目录中,然后将其读入环境

var privateKey = require('fs').readFileSync('./xxxxxxx.pem', {'encoding':'utf8'});

I may ask another question later to see if this is secure but I don't see why not. 稍后我可能会问另一个问题,以查看这是否安全,但我不知道为什么不这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM