Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

SSH Add on git

This document outlines the steps to perform Git operations via SSH, including generating SSH keys, adding them to the ssh-agent, and configuring them in Bitbucket. It details the commands needed to create and manage SSH keys, as well as how to update the remote URL for Git repositories. The process ensures secure and password-less access to Git repositories hosted on Bitbucket.

Uploaded by

Sudhanshu Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

SSH Add on git

This document outlines the steps to perform Git operations via SSH, including generating SSH keys, adding them to the ssh-agent, and configuring them in Bitbucket. It details the commands needed to create and manage SSH keys, as well as how to update the remote URL for Git repositories. The process ensures secure and password-less access to Git repositories hosted on Bitbucket.

Uploaded by

Sudhanshu Saxena
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Steps to perform git operations via SSH

1. From the terminal, enter ssh-keygen at the command line.


The command prompts you for a file to save the key in:

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/emmap1/.ssh/id_rsa):
-----------------PRESS ENTER-----------------------

2. Enter and re-enter a passphrase when prompted.


3. The command creates your default identity with its public and private keys. The whole
interaction will look similar to the following:

--------------------------------------------------------------------------
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/emmap1/.ssh/id_rsa):
Created directory '/Users/sudsaxena/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/sudsaxena/.ssh/id_rsa.
Your public key has been saved in /Users/sudsaxena/.ssh/id_rsa.pub.
The key fingerprint is:
4c:80:61:2c:00:3f:9d:dc:08:41:2e:c0:cf:b9:17:69 sudsaxena@myhost.local
The key's randomart image is:
+--[ RSA 2048]----+
|*o+ooo. |
|.+.=o+ . |
|. *.* o . |
|.=Eo |
| o.S |
| .. |
| . |
| |
| |
+-----------------+
---------------------------------------------------------------------------------------------------

4. List the contents of ~/.ssh to view the key files.

$ ls ~/.ssh
id_rsa id_rsa.pub
The command displays two files, one for the public key (for example id_rsa.pub) and one for
the private key (for example, id_rsa).

Step 2. Add the key to the ssh-agent

If you don't want to type your password each time you use the key, you'll need to add it to
the ssh-agent.
1.To start the agent, run the following:
$ eval `ssh-agent`
Agent pid 9700

2.Enter ssh-add followed by the path to the private key file:


$ ssh-add ~/.ssh/ id_rsa
Step 3. Add the public key to your Account settings
1.From Bitbucket, choose Personal settings from your avatar in the lower left.
2.Click SSH keys.
3. In your terminal window, copy the contents of your public key file. If you renamed the
key, replace id_rsa.pub with the public key file name.

On Linux, you can cat the contents:


$ cat ~/.ssh/id_rsa.pub

Select and copy the key output in the clipboard.


If you have problems with copy and paste, you can open the file directly with Notepad.
Select the contents of the file (just avoid selecting the end-of-file characters).
1.From Bitbucket, click Add key.
2.Enter a Label for your new key, for example, Default public key.
3.Paste the copied public key into the SSH Key field.
You may see an email address on the last line when you paste. It doesn't matter whether
or not you include the email address in the Key.
4.Click Save.
Bitbucket sends you an email to confirm the addition of the key.
5.Return to the terminal window and verify your configuration and username by entering
the following command:
$ ssh -T git@bitbucket.org

Change the remote URL to your repository

Update the URL for Git repositories


1.From a terminal, navigate to the repository. $ cd ~/<path_to_repo>
2.Run git remote -v to see the current remote URL.
$ git remote -v
origin https://sudsaxena@bitbucket.org/girnarsoftware/girnarsoft-hrmsv2.git (fetch)
origin https://sudsaxena@bitbucket.org/girnarsoftware/girnarsoft-hrmsv2.git (push)
3.Update the remote URL with git remote set-url using the current and new remote URLs.
$ git remote set-url origin ssh://sudsaxena@bitbucket.org/girnarsoftware/girnarsoft-hrmsv2.git

DONE!!!!

You might also like