User Tools

Site Tools


Go Back


You are not allowed to add pages


Gen new ssh key

1. Generate Key

command :

ssh-keygen -t rsa -C "your email" 
use all default configuration

example :

[dev@localhost ~]$ ssh-keygen -t rsa -C ""
Generating public/private rsa key pair.
Enter file in which to save the key (/home/dev/.ssh/id_rsa): 
Created directory '/home/dev/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/dev/.ssh/id_rsa.
Your public key has been saved in /home/dev/.ssh/
The key fingerprint is:

2. Check the key exist

command :

cd .ssh

example :

  [dev@localhost ~]$ pwd
  [dev@localhost ~]$ cd .ssh
  [dev@localhost .ssh]$ ls -al
  total 8
  drwx------. 2 dev dev   38 Nov 15 06:07 .
  drwx------. 6 dev dev  139 Nov 15 06:07 ..
  -rw-------. 1 dev dev 1679 Nov 15 06:07 id_rsa
  -rw-r--r--. 1 dev dev  395 Nov 15 06:07
  [dev@localhost .ssh]$ cat
  cat: No such file or directory
  [dev@localhost .ssh]$ cat

3. Add the key to server


// show the content,and copy the text,   paste the text to the server.


[dev@localhost .ssh]$ cat
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCilOM0VMp3YFZNQB1FT/6BZ/dzHSwIVhCS1bHGknYuDy9PK70GBeMTBQzxQMzOnF+cE4XubUwFqzLScq8OPHkQASIYpOXq9aA3ubZwo6TrXPTZTNcxA9G1dyozTaBJ0ispJ6DZgzRc88x0c6b1YCSLg734SERg8susz0YOtK+FG6H5RZX9WiA82NMH1FB9XA1Olrd3sVhzByyVMb3jFeEVssaCxj6dIA7nUff+8ZGR6+48hn7lQJf8oFmVUWW7xTYE/xM/7/QLqyyCTALpBro8y60TzgsEI+ebK9PXmkC51zyMfU50aqr72WoCo8jd9cvPD6ao7iwEVe+v8qQhalCP

4. Check the key to work

Before you set the key:

[dev@localhost proj]$ git clone
Cloning into 'meeting'...
The authenticity of host ' (' can't be established.
RSA key fingerprint is SHA256:ZrA2ZqYTVyPbw4zytCSAv74ZMaS2LDH74I7sMPtQIG0.
RSA key fingerprint is MD5:69:ab:cb:07:eb:a3:e1:f3:0b:2e:f4:23:b0:c1:c6:9a.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ',' (RSA) to the list of known hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

After you set the key:

[dev@localhost proj]$ git clone
Cloning into 'meeting'...
remote: Enumerating objects: 24, done.
remote: Counting objects: 100% (24/24), done.
remote: Total 24 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (24/24), 9.76 KiB | 0 bytes/s, done.
library/centos/sshkey.txt · Last modified: 2019/11/15 19:45 by lhaosen