自动化Heroku CLI登录 [英] Automate Heroku CLI login

查看:187
本文介绍了自动化Heroku CLI登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个bash脚本,以自动克隆开发VM中的某些项目和另一个任务,但是我们在Heroku中有一个项目,并且其中包含存储库.在我的.sh文件中,我有:

I'm developing a bash script to automatic clone some projects and another task in dev VM's, but we have one project in Heroku and repository is in it. In my .sh file I have:

> heroku login

然后提示输入凭据,我阅读了二进制文件和文档中包含的帮助"指南,但找不到自动插入用户名和密码的内容,我想要这样的东西:

And this prompt to enter credentials, I read the "help" guide included on binary and documentation but I can't found anything to automatic insert username and password, I want something like this:

> heroku login -u someUser -p mySecurePassword

存在任何类似的方式吗?

Exist any way similar to it?

推荐答案

Heroku CLI 仅使用您的用户名和密码来检索您的API密钥,它存储在您的~/.netrc文件(在Windows中为$HOME\_netrc).

The Heroku CLI only uses your username and password to retrieve your API key, which it stores in your ~/.netrc file ($HOME\_netrc on Windows).

您可以手动检索API密钥并将其添加到您的~/.netrc文件中:

You can manually retrieve your API key and add it to your ~/.netrc file:

  1. 登录到Heroku Web界面
  2. 导航到您的帐户设置页面
  3. 向下滚动到 API密钥部分,然后单击 Reveal 按钮
  4. 复制您的API密钥
  5. 使用您喜欢的文本编辑器打开或创建~/.netrc文件
  6. 添加以下内容:

  1. Log into the Heroku web interface
  2. Navigate to your Account settings page
  3. Scroll down to the API Key section and click the Reveal button
  4. Copy your API key
  5. Open your ~/.netrc file, or create it, with your favourite text editor
  6. Add the following content:

machine api.heroku.com
  login <your-email@address>
  password <your-api-key>
machine git.heroku.com
  login <your-email@address>
  password <your-api-key>

用在Heroku中注册的电子邮件地址替换<your-email@address>,并用从Heroku中复制的API密钥替换<your-api-key>.

Replace <your-email@address> with the email address registered with Heroku, and <your-api-key> with the API key you copied from Heroku.

这应该手动完成heroku login自动执行的操作. 但是,我不推荐这样做.运行heroku login可以更轻松地完成同一件事,并且犯错的机会更少.

This should manually accomplish what heroku login does automatically. However, I don't recommend this. Running heroku login does the same thing more easily and with fewer opportunities to make a mistake.

如果您决定在计算机或帐户之间复制~/.netrc文件,则应注意两个主要警告:

If you decide to copy ~/.netrc files between machines or accounts you should be aware of two major caveats:

  • This file is used by many other programs; be careful to only copy the configuration stanzas you want.
  • Your API key offers full programmatic access to your account. You should protect it as strongly as you protect your password.

如果您打算使用heroku login以外的任何机制登录Heroku,请非常小心.

Please be very careful if you intend to log into Heroku using any mechanism other than heroku login.

这篇关于自动化Heroku CLI登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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