Generate SSH public key
As mentioned earlier, many Git servers use ssh public keys for authentication. In order to provide the Git server with the ssh public key, if a system user does not already have the key, a copy must be generated in advance. This process is similar on all operating systems. First, you need to confirm whether you already have the key. By default, the user's ssh key is stored in its ~ / ssh directory. By entering the directory and listing the contents, you can quickly confirm whether you have the key:
$ cd ~/.ssh $ ls authorized_keys2 id_dsa known_hosts config id_dsa.pub
We need to find a pair with id_dsa or id_rsa named files, one with Pub extension The pub file is your public key and the other is the corresponding private key. If such files cannot be found (or there is no. SSH directory at all), you can create them by running the SSH keygen program. On Linux/macOS systems, SSH keygen is provided with the SSH package; on Windows, the program is included in the MSysGit package.
$ ssh-keygen -o Generating public/private rsa key pair. Enter file in which to save the key (/home/schacon/.ssh/id_rsa): Created directory '/home/schacon/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/schacon/.ssh/id_rsa. Your public key has been saved in /home/schacon/.ssh/id_rsa.pub. The key fingerprint is: d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 schacon@mylaptop.local
First, SSH keygen confirms where the key is stored (the default is. ssh/id_rsa), and then it will ask you to enter the key password twice. If you don't want to enter the password when using the key, just leave it blank. However, if you use the password, make sure to add the - o option, which will save the private key in a format more resistant to brute force cracking than the default format. You can also use the SSH agent tool to avoid having to enter it every time Enter the password.
Now, users who have done the above operations need to send their public keys to any Git server administrator (assuming that the server is using public key based SSH authentication settings). All they need to do is copy the contents of their. pub files and send them by mail. The public keys look like this:
$ cat ~/.ssh/id_rsa.pub ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3 Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx NrRFi9wrf+M7Q== schacon@mylaptop.local
1. Use the command first
ssh-keygen -o
2. Then the SSH command can be generated by constantly entering
3. ID found_ dsa. Pub file, which is Gong Yue. Copy it to the code cloud and add it
4. Test whether it is added successfully
ssh -T git@gitee.com
When successful English appears, the link is successful
The authenticity of host 'gitee.com (180.97.125.228)' can't be established. ED25519 key fingerprint is SHA256:+ULzij2u99B9eWYFTw1Q4ErYG/aepHLbu96PAUCoV88. This key is not known by any other names Are you sure you want to continue connecting (yes/no/[fingerprint])? yes Warning: Permanently added 'gitee.com' (ED25519) to the list of known hosts. Hi ××××××××! You've successfully authenticated, but GITEE.COM does not provide shell access.
ssh-keygen -o ✔ Generating public/private rsa key pair. Enter file in which to save the key (/home/huixing/.ssh/id_rsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/huixing/.ssh/id_rsa Your public key has been saved in /home/huixing/.ssh/id_rsa.pub The key fingerprint is: SHA256:mJRDIxaumLCaMnukCXy5Rr0u2NjNcrPJ4Fc02pJnxIk huixing@huixing-pc The key's randomart image is: +---[RSA 3072]----+ | +.o | | o o o | |. . * . | |.+ . E X | |= . o O S | |oo.+ = = | |*+B.+ * | |+=oBoB. | |....*=o | +----[SHA256]-----+