You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A credential helper for Terraform Cloud/Enterprise that allows secure storage of your API token within the operating system's vault instead of in a plain text configuration file.
6
+
A credential helper for Terraform Cloud/Enterprise that allows secure storage of your API token within the operating system's vault instead of in a plain text configuration file
7
7
8
-
We all know storing secrets in plain text can pose major security threats, and Terraform doesn't come pre-packaged with a credential helper, so we decided to create one and to share it with the greater Terraform/DevOps community to help enable stronger security practices.
8
+
We all know storing secrets in plain text can pose major security threats, and Terraform doesn't come pre-packaged with a credential helper, so we decided to create one and to share it with the greater Terraform/DevOps community to help enable stronger security practices
9
9
10
10
#### Currently supported Operating Systems:
11
11
-[x] Windows (Credential Manager)
12
12
-[x] MacOS (Keychain)
13
-
-[ ] Linux (ksecretservice or gnome-keyring)
14
-
15
-
*The Linux version is currently in development. If you'd like to support the project please feel free to submit a PR*
13
+
-[x] Linux (gnome-keyring) *Tested on Ubuntu 20.04*
16
14
17
15
## Windows Install via Chocolatey
18
16
The fastest way to install `terracreds` on Windows is via our Chocolatey package:
19
-
```bash
17
+
```powershell
20
18
choco install terracreds -y
21
19
```
22
20
23
21
Once installed run the following command to verify `terracreds` was installed properly:
24
-
```bash
22
+
```powershell
25
23
terracreds -v
26
24
```
25
+
26
+
To upgrade `terracreds` to the latest version with Chocolatey run the the following command:
27
+
```powershell
28
+
choco upgrade terracreds -y
29
+
```
30
+
27
31
## macOS Install
28
-
We are currently working on a `homebrew` package, however, to install the package simply download our latest release from this repository, extract the package, and then place it in a directory available on `$HOME`
32
+
We are currently working on a `homebrew` package, however, to install the package simply download our latest release from this repository,
33
+
extract the package, and then place it in a directory available on `$HOME`
34
+
35
+
## Linux Install
36
+
You'll need to download the latest binary from our release page and place it anywhere on `$PATH` of your system. You can also copy and run the following commands:
The `terracreds` Linux implementation uses `gnome-keyring` in conjunction with `gnome-keyring-daemon`
46
+
to utilize the credential storage engine
47
+
48
+
In order to leverage `terracreds` to have access to the default `Login` collection you'll need to unlock
49
+
the collection with `gnome-keyring-daemon` using an empty password:
50
+
51
+
```bash
52
+
echo""| gnome-keyring-daemon --unlock
53
+
```
54
+
> You do have the option of setting a password by passing it in with `echo` but every call to `terracreds get` will require the
55
+
unlock password
56
+
57
+
The command, if successful, should return the following:
58
+
```txt
59
+
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
60
+
```
29
61
30
-
## Manual Install
62
+
You can verify that it's running properly with:
63
+
```bash
64
+
ps -ef | grep 'gnome-keyring-daemon'
65
+
```
66
+
67
+
## Install From Source
31
68
Download the source files by entering the following command:
32
69
```go
33
70
go get github.com/tonedefev/terracreds
@@ -40,7 +77,7 @@ For Windows:
40
77
$env:GO111MODULE='on'
41
78
```
42
79
43
-
For macOS:
80
+
For macOS and Linux:
44
81
```bash
45
82
export GO111MODULE='on'
46
83
```
@@ -50,19 +87,22 @@ Once the files have been downloaded navigate to the `terracreds` directory in th
50
87
go install -v
51
88
```
52
89
53
-
Navigate to the root of the project directory and you should see the `terracreds.exe` binary for Windows or `terracreds` for macOS. On Windows, copy the `.exe` to any directory of your choosing. Be sure to add the directory on `$env:PATH` for Windows to make using the application easier. On macOS we recommend you place the binary in `/usr/bin` as this directory should already be on the `$PATH` environment variable.
90
+
Navigate to the root of the project directory and you should see the `terracreds.exe` binary for Windows or `terracreds` for macOS and Linux. On Windows, copy the `.exe` to any directory of your choosing. Be sure to add the directory on `$env:PATH` for Windows to make using the application easier. On macOS and Linux we recommend you place the binary in `/usr/bin` as this directory should already be on the `$PATH` environment variable
91
+
92
+
## Upgrading
93
+
If you're upgrading to the latest version of `terracreds` from a previous version use one of the methods above to install the latest binary. Once successfully installed on your system you just need to run `terracreds generate` to copy the latest version to the correct `plugins` directory for your operating system
54
94
55
95
## Initial Configuration
56
-
In order for `terracreds` to act as your credential provider you'll need to generate the binary and the plugin directory in the default location that Terraform looks for plugins. Specifically, for credential helpers, and for Windows, the directory is `%APPDATA%\terraform.d\plugins` and for macOS `$HOME/.terraformrc`
96
+
In order for `terracreds` to act as your credential provider you'll need to generate the binary and the plugin directory in the default location that Terraform looks for plugins. Specifically, for credential helpers, and for Windows, the directory is `%APPDATA%\terraform.d\plugins` and for macOS and Linux `$HOME/.terraform.d/.terraformrc`
57
97
58
98
To make things as simple as possible we created a helper command to generate everthing needed to use the app. All you need to do is run the following command in `terracreds` to generate the plugin directory, and the correctly formatted binary that Terraform will use:
59
99
```bash
60
100
terracreds generate
61
101
```
62
102
63
-
This command will generate the binary as `terraform-credentials-terracreds.exe` for Windows or `terraform-credentials-terracreds` for macOS which is the valid naming convention for Terraform to recognize this plugin as a credential helper.
103
+
This command will generate the binary as `terraform-credentials-terracreds.exe` for Windows or `terraform-credentials-terracreds` for macOS and Linux which is the valid naming convention for Terraform to recognize this plugin as a credential helper
64
104
65
-
In addition to the binary and plugin a `terraform.rc` file is required for Windows or `.terraformrc` for macOS with a `credentials_helper` block which instructs Terraform to use the specified credential helper. If you don't already have a `terraform.rc` or a `.terraformrc` file you can pass in `--create-cli-config` to create the file with the credentials helper block already generated for use with the `terracreds` binary for your OS.
105
+
In addition to the binary and plugin a `terraform.rc` file is required for Windows or `.terraformrc` for macOS and Linux with a `credentials_helper` block which instructs Terraform to use the specified credential helper. If you don't already have a `terraform.rc` or a `.terraformrc` file you can pass in `--create-cli-config` to create the file with the credentials helper block already generated for use with the `terracreds` binary for your OS
66
106
67
107
However, if you already have a `terraform.rc` or `.terraformrc` file you will need to add the following block to your file instead:
Once you have moved all of your tokens from this file to the `Windows Credential Manager` or `KeyChain` via `terracreds` you can remove the tokens from the file. If you don't remove the tokens, and you add the `credentials_helper` block to this file, Terraform will still use the tokens instead of `terracreds` to retreive the tokens, so be sure to remove your tokens from this file once you have used the `create` command to create the credentials in `terracreds` so you can actually leverage the credential helper.
115
+
Once you have moved all of your tokens from this file to the `Windows Credential Manager` or `KeyChain` via `terracreds` you can remove the tokens from the file. If you don't remove the tokens, and you add the `credentials_helper` block to this file, Terraform will still use the tokens instead of `terracreds` to retreive the tokens, so be sure to remove your tokens from this file once you have used the `create`or `terraform login`command to create the credentials in `terracreds` so you can actually leverage the credential helper
76
116
77
117
## Storing Credentials
78
-
For Terraform to properly use the credentials stored in your credential manager they need to be stored a specific way. The name of the credential object must be the domain name of the Terraform Cloud or Enterprise server. For instance `app.terraform.io` which is the default name `terraform login` will use.
118
+
For Terraform to properly use the credentials stored in your credential manager they need to be stored a specific way. The name of the credential object must be the domain name of the Terraform Cloud or Enterprise server. For instance `app.terraform.io` which is the default name `terraform login` will use
79
119
80
-
The value for the password will correspond to the API token associated for that specific Terraform Cloud or Enterprise server.
120
+
The value for the password will correspond to the API token associated for that specific Terraform Cloud or Enterprise server
81
121
82
122
The entire process is kicked off directly from the Terraform CLI. Run `terraform login` to start the login process with Terraform Cloud. If you're using Terraform Enterprise you'll need to pass the hostname of the server as an additional argument `terraform login my.tfe.com`
83
123
@@ -119,7 +159,7 @@ If the token was updated successfully the following message is returned:
119
159
Success! Terraform has obtained and saved an API token.
120
160
```
121
161
122
-
Additionally, you can check the `terracreds.log` if logging is enabled for more information.
162
+
Additionally, you can check the `terracreds.log` if logging is enabled for more information
123
163
124
164
## Forgetting Credentials
125
165
You can delete the credential object at any time by running:
@@ -137,14 +177,14 @@ If the credential was successfully deleted `terraform` will return:
137
177
Success! Terraform has removed the stored API token for app.terraform.io.
138
178
```
139
179
140
-
Additionally, you can check the `terracreds.log` if logging is enabled for more information.
180
+
Additionally, you can check the `terracreds.log` if logging is enabled for more information
141
181
142
182
## Protection
143
-
In order to add some protection `terracreds` adds a username to the credential object, and checks to ensure that the user requesting access to the token is the same user as the token's creator. This means that only the user account used to create the token can view the token from `terracreds` which ensures that the token can only be read by the account used to create it. Any attempt to access or modify this token from `terracreds` outside of the user that created the credentail will lead to denial messages. Additionally, if the credential name is not found, the same access denied message will be provided in lieu of a generic not found message to help prevent brute force attempts.
183
+
In order to add some protection `terracreds` adds a username to the credential object, and checks to ensure that the user requesting access to the token is the same user as the token's creator. This means that only the user account used to create the token can view the token from `terracreds` which ensures that the token can only be read by the account used to create it. Any attempt to access or modify this token from `terracreds` outside of the user that created the credentail will lead to denial messages. Additionally, if the credential name is not found, the same access denied message will be provided in lieu of a generic not found message to help prevent brute force attempts
144
184
145
185
## Logging
146
-
Wherever either binary is stored `terracreds` or `terraform-credential-terracreds` a `config.yaml` file is generated on first launch of the binary. Currently, this configuration file only enables/disables logging and sets the log path. If logging is enabled you'll find the log named `terracreds.log` at the provided path.
147
-
>It's important to note that you'll have two configuration files due to Terraform requiring that the credential helper have a very specific binary name, so when troubleshooting credential issues with Terraform remember to setup the configuration file in the `%APPDATA%\terraform.d\plugins` directory for Windows and `$HOME/.terraformrc` directory for macOS.
186
+
Wherever either binary is stored `terracreds` or `terraform-credential-terracreds` a `config.yaml` file is generated on first launch of the binary. Currently, this configuration file only enables/disables logging and sets the log path. If logging is enabled you'll find the log named `terracreds.log` at the provided path
187
+
>It's important to note that you'll have two configuration files due to Terraform requiring that the credential helper have a very specific binary name, so when troubleshooting credential issues with Terraform remember to setup the configuration file in the `%APPDATA%\terraform.d\plugins` directory for Windows and `$HOME/.terraform.d/plugins` directory for macOS and Linux
148
188
149
189
To enable logging for Windows setup the `config.yaml` as follows:
150
190
```yaml
@@ -153,11 +193,30 @@ logging:
153
193
path: C:\Temp\
154
194
```
155
195
156
-
To enable logging for macOS:
196
+
To enable logging for macOS and Linux:
157
197
```yaml
158
198
logging:
159
199
enabled: true
160
-
path: /usr/
200
+
path: /home/username/
161
201
```
162
202
163
203
The log is helpful in understanding if an object was found, deleted, updated or added, and will be found at the path defined in the configuration file as `terracreds.log`
204
+
205
+
In addition all error messages returned by the underlying libraries will be logged when logging is enabled and an error is encountered
206
+
207
+
## Troubleshooting Linux
208
+
If you are having trouble viewing, deleting, or saving credentials on Linux systems using `gnome-keyring` you must ensure that you have unlocked the collection using `gnome-keyring-daemon --unlock` otherwise you will see the following error message in the logs:
209
+
210
+
```txt
211
+
ERROR: <TIMESTAMP> - failed to unlock correct collection '/org/freedesktop/secrets/collection/login'
212
+
```
213
+
214
+
If the daemon has unlocked the collection but you're still getting prompted for credentials --
215
+
check to make sure that only a single instance of the daemon is running:
216
+
217
+
```bash
218
+
ps -ef | grep gnome-keyring
219
+
```
220
+
221
+
If more than one daemon is running, take note of the pid, and use `kill` to terminate the additional daemon. Try your previous command again
0 commit comments