SSH with version control system

Md. KaiyomMd. Kaiyom
2 min read

Run SSH in your machine.

sudo systemctl start sshd

Run SSH in machine startup, so that you do not have to do the above command again in future.

sudo systemctl enable sshd

» Created symlink '/etc/systemd/system/multi-user.target.wants/sshd.service' → '/usr/lib/systemd/system/sshd.service'.

Create a unique key to connect with github/bitbucket, so that anytime you pull or push code from it won’t as you for password. Bitbucket will identify and authorize based on the key.

ssh-keygen -t ed25519 -C "your_email@example.com" -f ~/.ssh/id_ed25519_bitbucket

» Will prompt you to enter a passphrase twice. [You can use your pc login password ;-) ]

Re-check to be extra sure that SSH is running.

eval "$(ssh-agent -s)"

» Agent pid 7660 give you something like this. This output means the SSH service is running in your machine.

Now add the newly create key into SSH database.

ssh-add ~/.ssh/id_ed25519_bitbucket

» It will again ask for passphrase you entered earlier.

Let check all the key have

ls -al ~/.ssh

Now we have to give the (.pub) public copy of the key to github/bitbucket.

To avoid running ssh-add for every new session, we can run the following command once and the keychain will store the passphrase and reload that in every session automatically.

# install keychain if it does not exist in you machine
eval $(keychain --quiet --eval ~/.ssh/id_ed25519_bitbucket)

For bitbucket:

Click the setting (cog icon) on the top right next to profile icon > Personal bitbucket settings > SSH keys

Now click add key, on the form give a name and

cat ~/.ssh/id_ed25519_bitbucket.pub

copy the output and paste SSH public key field, and click Save.

That’s it. You can now pull and push new code anytime without typing bitbucket password.

For github:

Settings >

0
Subscribe to my newsletter

Read articles from Md. Kaiyom directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Md. Kaiyom
Md. Kaiyom

To live in hearts we leave behind is not to die