Always need to renew ssh-keys working with Bitbucket from two machines
I've never had any problems working with my repos hosted on Bitbucket using SSH connection with a generated keypair. But since I'm accessing my repos from two different machines (e.g. home machine, work machine), I always get
Permission denied (publickey).fatal: Could not read from remote repository.
everytime I switch machines. So my current not so great workaround is to delete my current key with
rm -r .ssh
(I'm just using one) and then generate a new one, either using Sourcetree or Terminal. Then I remove the old key for the machine I'm using from my Bitbucket Account and paste in the new key.
This has been working since, but there has to be a better solution. I've browsed the Bitbucket docs, but it just says to add a new key for every machine, which is accessing the repos and obviously this it not working. I'm sure I'm missing something. Thanks for any help!
You should add ssh keys both from your home machine and work machine into your bitbucket account.
The whole steps to add ssh keys to bitbucket as below (you can skip the steps which you have already done):
Generate SSH Key in home machine
In your home machine, execute
ssh-keygencommand. And it will generate ssh key in your local machine. Copy the content of the public key
id_rsa.pubto add it in bitbucket (as step2 shows).
Add the ssh key from home machine to bitbucket
In bitbucket home page -> Bitbucket settings (https://bitbucket.org/account/user/username) -> SSH keys -> Add key -> paste the content of
id_rsa.pub(in step1) to the key option -> Add key.
Generate SSH key in work machine
In work machine, execute ssh-keygen command. And it will generate ssh key in your local machine. Paste the content of the public key
id_rsa.pubto add it in bitbucket (as step4 shows).
Add the SSH key from work machine to bitbucket
Click Add key in SSH key Hub of the bitbucket, and then paste the conent of
Now connect bitbucket repo with both home machine and work machine can be accessed.
If you still can not access to bitbucket repo vis ssh key, please troubleshooting by the command
ssh -T email@example.com.
Details, you can refer the document Permission denied (publickey).
git, Always need to renew ssh-keys working with Bitbucket from two from two different machines (e.g. home machine, work machine), I always get Whichever way you add an SSH key, the private key is automatically added to the build pipeline (as an additional SSH key), and doesn't need to be specified in the bitbucket-pipelines.yml file. If your Docker image already has an SSH key your build pipeline can use that key, and you don't need to add an SSH key in this step – go to Step 2 !
Make sure when you're adding the 2nd key, you're not affecting the 1st. https://confluence.atlassian.com/bitbucket/set-up-additional-ssh-keys-271943168.html
If you can't make bit bucket work with 2 keys, you can use the same key on both machines. Just copy the
~/.ssh directory from whichever machine currently works to the other.
Can I have multiple ssh keys in my .ssh folder?, Always need to renew ssh-keys working with Bitbucket from two machines - git. from two different machines (e.g. home machine, work machine), I always get Need to report the video? Eliminate Password on git push by Generating SSH keys for Github Mike Levin 15,231 views. 11:33. Bitbucket Server - Create a project, repository, and set
So here is a link to a guide on how to fix that problem.
As described in the comments, Apple changed SSH behavior in Sierra/High Sierra. Theres a Sourcetree issue with status 'resolved' about this topic (https://jira.atlassian.com/browse/SRCTREE-4499), so Sourcetree adds keys to
.ssh/config with the needed flags since 2.7.2 but still this hasn't worked for me. I needed to add
ssh-add -Ato my launch agents.
Add SSH key for both github and bitbucket in single PC, Can I use the same SSH key for GitHub and Bitbucket? Use SSH keys to connect to Bitbucket Server repositories. SSH access needs to have been set up, as described above. Once this is done, you can use SSH keys as follows: Go to Projects, click a project, and choose a repository from the list. Click Clone in the sidebar to see the clone URLs for the repository.
Best Practice: ”separate ssh-key per host and user“ vs. ”one ssh-key , for your work, etc. Next, append the contents of your id_rsa. Now you need to enter a bit length. The recommendation is 4096 bits. After that you can specify a expiration length or if the key should never expire. Pick as you want. Expiring keys are more secure in general because you have to renew them every now and then. Now enter your personal informations to verifying your identity with your gpg key.
Multiple public keys for one user, For example, if you have a work-related Bitbucket account and a personal You're using two different computers to log in to the same account. Generating and Working with SSH Keys This section will cover how to generate SSH keys on a client machine and distribute the public key to servers where they should be used. This is a good section to start with if you have not previously generated keys due to the increased security that it allows for future connections.
Set up additional SSH keys, Peter Van de Voorde April 13, 2016 2 min read. Share. Reading To add a public key to a Bitbucket account, you need to go to the Bitbucket Settings Screen. Select SSH If you already have a local copy, you'll need to update the origin: If you have root access to the server, the easy way to solve such problems is to run sshd in debug mode, by issuing something like /usr/sbin/sshd -d -p 2222 on the server (full path to sshd executable required, which sshd can help) and then connecting from the client with ssh -p 2222 user@host.