An Interest In:
Web News this Week
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
- April 19, 2024
ssh - a treat for your GitHub
ssh commands
ssh creation
- ssh key should be in /home/.ssh folder
- to generate ssh key-
ssh-keygen
- the command will ask you the name of the file, you can enter it. Let say, you named it "secure-shell" and follow the next instructions:
It will create two files in the same folder one is a public key file with extension .pub file and the other one is a private file. In our case, it will create "secure-shell.pub" and "secure-shell"
It needs your attention,
secure-shell - never share this with anybody
secure-shell.pub -to be share with a remote server that you want to excess
- When you have multiple private keys then you have to add a specific key to your main identity.
eval $(ssh-agent)
ssh-add ~/.ssh/secure-shell
difference ssh-add /.ssh/secure-shell V/S ssh -i /.ssh/secure-shell ?
add will set the identity of your system for a current pointed ssh key for every commit, whether -i will set temp identity pass key(ssh key) in case you have different ssh keys added to the different remote workspaces.
GitHub access
- write the following command to view the ssh-key (we will use secure-shell i.e. our key name). Please access the directory where your ssh key present.> cat .ssh/secure-shell.pub
- The above command lists a key, copy it!!
- Goto git account, setting > SSH and GPG keys > New ssh key and paste here
- that it
- Remember, you need to generate two ssh keys to access two different git accounts. Each git account will require a unique ssh key to be added. It is a good practice.
Remote access
- On your local machine > cat .ssh/secure-shell.pub
- The above command lists a key, copy it!!
- go to the remote machine and write following command > sudo vi .ssh/authorized_key
- Press i button to write
- paste your key here and press ESC button
- Write :wq
NOTE - how to know which ssh is currently added
ssh-add -l
It's pretty simple, right !!
Original Link: https://dev.to/imabtiwari/ssh-a-treat-for-your-github-18p2
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To