Skip to content

Commit d058bc5

Browse files
ereadAnton Smith
andcommitted
Merge branch 'docs/rotating-gitlab-secrets-json-file' into 'master'
Rotating the /etc/gitlab/gitlab-secrets.json file See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7222 Merged-by: Evan Read <[email protected]> Approved-by: Balasankar 'Balu' C <[email protected]> Approved-by: Hossein Pursultani <[email protected]> Approved-by: Evan Read <[email protected]> Reviewed-by: Evan Read <[email protected]> Co-authored-by: Anton Smith <[email protected]>
2 parents 857e7bf + f867371 commit d058bc5

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

doc/maintenance/index.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,68 @@ To remove the page, you simply run `sudo gitlab-ctl deploy-page down`. You can a
155155
As a side note, if you would like to restrict logging into GitLab and restrict
156156
changes to projects, you can [set projects as read-only](https://docs.gitlab.com/ee/administration/troubleshooting/gitlab_rails_cheat_sheet.html#make-a-project-read-only-can-only-be-done-in-the-console)
157157
, then put up the `Deploy in progress` page.
158+
159+
## Rotate the secrets file
160+
161+
If required for security purposes, you can rotate the `/etc/gitlab/gitlab-secrets.json` secrets file. In this file:
162+
163+
- Do not rotate the `gitlab_rails` secrets because it contains the database encryption keys. If this secret is rotated, you see the same
164+
behavior as [when the secrets file is lost](https://docs.gitlab.com/ee/administration/backup_restore/backup_gitlab.html#when-the-secrets-file-is-lost).
165+
- You can rotate all other secrets.
166+
167+
If you have multiple nodes in your GitLab environment, choose one of your Rails node to perform the initial steps.
168+
169+
To rotate the secrets:
170+
171+
1. [Verify that the database values can be decrypted](https://docs.gitlab.com/ee/administration/raketasks/check.html#verify-database-values-can-be-decrypted-using-the-current-secrets) and either make note of any decryption errors shown, or resolve
172+
them before proceeding.
173+
174+
1. Recommended. Extract your current secrets for `gitlab_rails`. Save the output because you need this later:
175+
176+
```shell
177+
sudo grep "secret_key_base\|db_key_base\|otp_key_base\|encrypted_settings_key_base\|openid_connect_signing_key\|ci_jwt_signing_key" /etc/gitlab/gitlab-secrets.json
178+
```
179+
180+
1. Move your current secrets file to a different location:
181+
182+
```shell
183+
sudo mv /etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab-secrets.json.old
184+
```
185+
186+
1. [Reconfigure GitLab](https://docs.gitlab.com/ee/administration/restart_gitlab.html#reconfigure-a-linux-package-installation). GitLab will
187+
then generate a new `/etc/gitlab/gitlab-secrets.json` file with new secret values.
188+
189+
1. If you extracted the previous secrets for `gitlab_rails`, edit the new `/etc/gitlab/gitlab-secrets.json` file and replace the key/value pairs
190+
under `gitlab_rails` with the previous secrets output obtained earlier.
191+
192+
1. [Reconfigure GitLab](https://docs.gitlab.com/ee/administration/restart_gitlab.html#reconfigure-a-linux-package-installation) again
193+
so the changes made to the secrets file are applied.
194+
195+
1. [Restart GitLab](https://docs.gitlab.com/ee/administration/restart_gitlab.html#restart-a-linux-package-installation) to ensure all services
196+
are using the new secrets.
197+
198+
1. If you have multiple nodes in your GitLab environment, you must copy the secrets to all of your other nodes:
199+
200+
1. On all other nodes, move your current secrets file to a different location:
201+
202+
```shell
203+
sudo mv /etc/gitlab/gitlab-secrets.json /etc/gitlab/gitlab-secrets.json.old
204+
```
205+
206+
1. Copy the new `/etc/gitlab/gitlab-secrets.json` file from your Rails node onto all of your other GitLab nodes.
207+
208+
1. On all other nodes, [reconfigure GitLab](https://docs.gitlab.com/ee/administration/restart_gitlab.html#reconfigure-a-linux-package-installation)
209+
on each node.
210+
211+
1. On all other nodes, [restart GitLab](https://docs.gitlab.com/ee/administration/restart_gitlab.html#restart-a-linux-package-installation) on each
212+
node to ensure all services are using the new secrets.
213+
214+
1. On all nodes, run a checksum match on the `/etc/gitlab/gitlab-secrets.json` file to confirm that the secrets match:
215+
216+
```shell
217+
sudo md5sum /etc/gitlab/gitlab-secrets.json
218+
```
219+
220+
1. [Verify that the database values can be decrypted](https://docs.gitlab.com/ee/administration/raketasks/check.html#verify-database-values-can-be-decrypted-using-the-current-secrets). The output should match with the previous execution.
221+
222+
1. Confirm that GitLab is working as expected. If it is, it should be safe to delete the old secrets.

0 commit comments

Comments
 (0)