Set up your pub key
On a new computer where you want to set up your github account, first check if your public key exists already or not
$ ls -lart ~/.ssh
to see if existing SSH keys are present. If none is,
$ ssh-keygen -t ed25519 -C "your_email@example.com"
Press enter when prompted for a passphrase if you want it to be blank.
If you are using a legacy system that doesn’t support the Ed25519 algorithm, use:
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com" $ cat ~/.ssh/id_ed25519.pub
Set up things globally
On the laptop your username and email, run
$ git config --global user.name myusername $ git config --global user.email myemail
rsa type of pgp keys
For some reason, sometimes github protests and does not accept this new version of keygen, so that I do the following
$ ssh-keygen -t rsa -b 4096 -C "amaro@riseup.net"
If github is protesting with this kind of message:
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: UNPROTECTED PRIVATE KEY FILE! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ Permissions 0644 for '/home/pau/.ssh/id_rsa' are too open. It is required that your private key files are NOT accessible by others. This private key will be ignored. Load key "/home/pau/.ssh/id_rsa": bad permissions git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.
do the following:
$ chmod 600 ~/.ssh/id_rsa
Upload the key to github
- Then select and copy the contents of the xxxxxx.pub file displayed in the terminal to your clipboard.
- Then login on github.com and in the upper-right corner of any page, click your profile photo, then click “Settings”.
- In the “Access” section of the sidebar, click SSH and GPG keys
- Click New SSH key or Add SSH key.
- In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal laptop, you might call this key “Personal laptop”.
How to ssh or scp without being prompted
Now that you have created the ssh keys without a password on machine 2, from your laptop, machine 1, you can do the following to scp or ssh without being asked for a password
$ scp $HOME/.ssh/id_rsa.pub pau@machine2.blabla.blo.org:$HOME/.ssh/authorized_keys2