Why my ssh key is getting expire every day ?

Md Kamran
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 21, 2025

I am generating ssh key, but the next day any pull,push,fetch is not working and getting below error:

Fetching origin git@bitbucket.org: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. error: Could not fetch origin


I am using below link to geneate token:

https://support.atlassian.com/bitbucket-cloud/docs/set-up-personal-ssh-keys-on-linux/

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 22, 2025

Hi @Md Kamran and welcome to the community!

Your SSH key may be getting removed from the SSH agent on your machine and your SSH client may not be offering it when you try to pull, push or fetch the next day.

Do you have a file named config in the ~/.ssh directory on your machine? If not, you can create the directory and file, and then add the following content to the file:

Host bitbucket.org
AddKeysToAgent yes
IdentityFile ~/.ssh/{ssh-key-name}

where {ssh-key-name} replace with the name of the private SSH key, whose public key you have uploaded to your Bitbucket account.

Please also note that the SSH key pair needs to exist in the ~/.ssh directory on your machine to work with this config. If the SSH key pair is in a different directory, please move it inside ~/.ssh.

 

If you are still facing issues after you follow these steps, could you please provide the following information so I can better help you?

  1. Is the public SSH key added on the SSH keys of your account, here https://bitbucket.org/account/settings/ssh-keys/ ?

  2. Please run the Git command that fails from a terminal application and add to the command GIT_SSH_COMMAND="ssh -vvv", as follows:
    GIT_SSH_COMMAND="ssh -vvv" <git command here>

    and then shared the full output here. This will give more verbose output and it will show us which SSH keys are offered and if your config is applied.

  3. Please also share the name of the private SSH key file, so we can see if it is offered in the output of the previous command.

 

Please feel free to let me know if you have any questions.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events