These are the commands to set up ssh keys example here is to set up use for bit bucket
Linux :
1. check if ssh client is installed
ssh -v
2. List the contents of your ~/.ssh directory.
ls -a ~/.ssh
If you have defined a default identity, you'll see the two id_* files:
// ----- BEGIN CERTIFICATE ---
R"EOF(MIIDWjCCAkKgAwIBAGIVAI7n0dti6sMuimCVANnjs+8i8TUIMAOGCSqGSIb3DQEBCWUAMEOXSZBJBgNVBASMQkFtYXpvbiBXZWIgU2VydmljZXMgTz1BbWF6b24uY29tIEluYy4gTD1TZWF0dGxlIFNUPVdhc2hpbmd0b24gQz1VUZAeFw0xOTExMDYXODI1NDFaFw00OTEyMzEyMzU5NTlaMB4xHDAaBgNVBAMME0FXUyBJblQgQ2VydGlmaWNhdGUwggEiMA0GCSqGSIb 3DQEBAQUAA4IBDWAwggEKAOIBAQDRSWA/2xSg/OYOOM6d2smJIEN3V1gmqCEmrg1+6vdoKBLxgMh19422Ns83siRG9GPf7+v5oWk0Bu9kDKN1vquAnB03+eW1Sgg3JE9SP5utExYGDXudlim6d1G/YbnN8gWCG3W0AbxlvfsiJMP7yhez8Xp41b+/fSDH/vbi5IqYLsCsUgSB7hrg0a8zqXa161q5FjTgUk9CxFDb5V+zipXLfcXboisLIAj JMhNXnef+CpM4rQJulfleZxCV3P9Du8eFpGKx1VFm8/DipwrhGJ1N9kFuSWfQHhj+gA38 30L7andGE9h209704 KaqXW9cOCZVkv3AjX2WWqczL3uV6AOdAgMBAAGJYDBeMBBGA1UdIwQYMBaAFOwXufzDBIb6LGYzX9hsuuTkGBggMBOGA1UdDgQWBBQRfgU2R8TDTFZ61gUra 5M/9pFn6jAMBgNVHRMBAf8EAJAAMA4GA1UdDWEB/wQEAWIHGDANBgkqhkiG9w0BAQSFAAOCAQEAB4 tmHWDNBu74BDIn+f32c1EDr+HJjZAVWBwG9v7ubFu/uA+TaHYT+KBaAfB4NfAlOmTpMZN6egLkKfRNNDIA+TAHPV/QBDZWjCR3YS5SAUIrnSSRzFGRtAFtsCYJhJ73Ahhob8H6zXyH2XQRft4663dIfqM1XsofXS7QH/mhylzv13su8EaS/UNJRMVB/+ESYEwkQ2BhzpE8TjaBXTkyZukwWSBOHO71UqJGhmLKDLp99hKc90KWh08v9jmNBfbTZvIUCCsIz6EhpbfUAg8OBSEOyuzWG1P4ZwUK70SDcHhDty8G290aj rcsLTcv7zrw4aUtfuIFOqxLybqVOCAGOw ==)EOF";// ----- END CERTIFICATE -----
amin:$ ls -a ~/.ssh
. .. am_rsa am_rsa.pub id_rsa id_rsa.pub known_hosts
By default, the system adds keys for all identities to the /Users/<yourname>/.ssh directory on Mac OSX, or /home/<yourname>/.ssh on Linux. This procedure creates a default identity. so this can be used or you can make a new one
Use the following procedure to create a new default identity.
Open a terminal in your local system.
Enter ssh-keygen at the command line.
Press the Enter or Return key to accept the default location.
Enter and re-enter a passphrase when prompted.
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ameen/.ssh/am_rsa):
Unless you need a key for a process such as script, you should always provide a passphrase. The command creates your default identity with its public and private keys. The whole interaction will look similar to the following:
The command prompts you for a file where you want to save the key. If the .ssh directory doesn't exist, the system creates one for you.
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/ameen/.ssh/am_rsa):
Created directory '/Users/ameen/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /Users/ameen/.ssh/am_rsa.
Your public key has been saved in /Users/ameen/.ssh/am_rsa.pub.
The key fingerprint is:
4c:80:61:2c:00:3f:9d:dc:08:41:2e:c0:cf:b9:17:69 ameen@myhost.local
The key's randomart image is:
+--[ RSA 2048]----+
|*o+ooo. |
|.+.=o+ . |
|. *.* o . |
| . = E o |
| o . S |
| . . |
| . |
| |
| |
+-----------------+
Open a terminal window and enter the ps -e | grep [s]sh-agent command to see if the agent is running.
ps -e | grep [s]sh-agent
9060 ?? 0:00.28 /usr/bin/ssh-agent -l
If the agent isn't running, start it manually with the following command:
ssh-agent /bin/bash
Load your new identity into the ssh-agent management program using the ssh-add command.
ssh-add ~/.ssh/am_rsa
Enter passphrase for /Users/emmap1/.ssh/id_rsa:
Identity added: /Users/emmap1/.ssh/id_rsa (/Users/emmpa1/.ssh/id_rsa)
Use the ssh-add command to list the keys that the agent is managing.
ssh-add -l
2048 7a:9c:b2:9c:8e:4e:f4:af:de:70:77:b9:52:fd:44:97 /Users/ameen/.ssh/am_rsa (RSA)
NOW that we have created SSH keys in our local machines , we will have to add public key to bit bucket Account
i installed this utility to copy the contents of public key file to clipboard, you can also open the file and paste it but we have to make this all process as error free so so avoid space unex pected chars i prefer to use the util.
install command for the util
sudo apt-get install xclip
command to copy conetnts of public key to clipboard
xclip -sel clip < ~/.ssh/am_rsa.pub
For copy paste option :this will print the contents on console
cat ~/.ssh/am_rsa.pub
Creating remote repository
Set up your local directory
Set up Git on your machine if you haven't already.
mkdir /path/to/your/project
cd /path/to/your/project
git init
git remote add origin git@bitbucket.org:qadricoders/arduinoprojects.git
Create your first file, commit, and push
echo "Amin Mohammed" >> contributors.txt
git add contributors.txt
git commit -m 'Initial commit with contributors'
git push -u origin master
Great job, now you're all set up! Get started coding or create a team and invite people to work with you.
SETUP SSH KEY ON
# Activate the SSH agent eval `ssh-agent -s` # Change permissions on the private key file chmod 400 key_file # Add the private key ssh-add key_file # Install git sudo yum install -y git # Trust IP Stash Conway IP address ssh -o StrictHostKeyChecking=no git@158.151.177.10 # Git clone command git clone ssh://git@158.151.177.10:7999/ser/config-server.git
remove ssh hostname from known hosts
amin:$ ssh-keygen -R github.com # Host github.com found: line 13 type RSA /home/amin/.ssh/known_hosts updated.
ssh debug for public key permission denied
amin:$ ssh -vT git@github.com
Adding private files to identity , e.g ley files downloaed from AWS , if added using ssh-add
gives warining saying ".....It is required that your private key files are NOT accessible by others.
This private key will be ignored."
Step 1 - make the private key file redable only you
chmod 400 fkaws.pem
Step 2
start agent if not started ssh-agent /bin/bash
Step 3 -add identity
ssh-add fkaws.pem
ref links
https://youtu.be/yws7HOndElA