-->

Monday, June 3, 2024

[Solved] Gitlab remote: ERROR: Your SSH key has expired.

 Error:-

We have been using Gitlab and recently I got the following error while pushing my change to the Gitlab Repository


remote:
remote: ========================================================================
remote:
remote: ERROR: Your SSH key has expired.

remote:
remote: ========================================================================
remote:
fatal: Could not read from remote repository.


Cause:-

The reason for this failure was that i created a ssh key about a year ago and gitlab by default puts a security policy that your ssh key will get expire after 1 year. This is something built in to improve security in Gitlab now because that timeperiod has elapsed of 1 year thats why it gives that error of ssh key has expired.


Solution :-

Obviously one of the solution is to create a new ssh key and replace your current key with new key in the Gitlab and all other repositories.

But in our case we have private Gitlab repository plus i dont want to change in all the other repositories because if i generate new ssh key it needs to be changed across all other providers as well. So we have following workaround to overcome this issue.

Go under the Gitlab

user---> user settings ---> ssh keys

1. Delete your existing key from the Gitlab.

2. After deleting again copy the same key which was previously expired. Gitlab would consider it as new key and you will again get 1  year validity so can keep using same key again.


Although this workaround works but it might not be best security practice. So better to generate new ssh key and use it. But in case you are struck and might want to do that at later time can use this way to overcome issue and later change your key without being blocked by this issue for now.

0 comments:

Post a Comment