8

I was using git on a remote server (Ubuntu 14.04 LTS). It works smoothly, until a certain amount of time passed by. I was denied access to the repository (no this issue on my local machine). How does this happen? And is there anyway to solve it?

2
  • Your title is your answer: SSH keys expire. Generate a new one.
    – elixenide
    Oct 1, 2015 at 14:42
  • @EdCottrell I'm sorry I did not described it clearly. It's the key 'stops' functioning after a while, a re-log in helps it. Oct 1, 2015 at 15:40

4 Answers 4

7

First, an ssh key does not "expire" (ssl certificates do, but that is another topic). They are revoked (removed from the .authorized_keys on the remote side)

(Update August 2019: as shown in "SSH certificate authentication for GitHub Enterprise Cloud", SSH allows one SSH key (a certificate authority) to sign another SSH key, along with information about the developer it belongs to. And that include an expiration date)

Second, if it was working and no longer work, something must have changed, like the $HOME value (since ssh looks for a public/private key in $HOME/.ssh)

If is possible that the process using ssh does not run with the usual account, but with another user (or with root if preceded by sudo)

2
  • It "expires" a while after re-log in Oct 1, 2015 at 15:39
  • 2
    Then it sounds like a ssh-agent issue
    – VonC
    Oct 1, 2015 at 16:13
1

I just had to re-add my key to Github (same key as before it stopped working, did not have to make a new key) and I could then instantly resume working remote Git commands. I did not have to remove "prior" key "copy" (it was still displayed as, "Last used within the last week"). definitely mysterious why it stopped working before, but I guess whatev

1
  • Same thing happened to me. Github was still showing the SSH key as active, but my Docker build which needs SSH access to my repository kept returning a "Permission denied (publickey)" error. Finally, I just deleted it and re-added it, and it worked.
    – ScottyB
    Apr 23, 2023 at 19:49
0

Another possibility - if the git server is moved seamlessly to another Linux machine (keeping the same IP). In this case this new git server will have new ssh key.

0

Check that the (GMT) time is reasonably close on both systems: some, if not all, ssh implementations insist on coordinated time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.