创建 ssh key

2020-12-04  

help 页内容

SSH keys

An SSH key allows you to establish a secure connection between your computer and GitLab. Before generating an SSH key in your shell, check if your system already has one by running the following command:

Windows Command Line:

type %userprofile%\.ssh\id_rsa.pub

GNU/Linux/Mac/PowerShell:

cat ~/.ssh/id_rsa.pub

If you see a long string starting with ssh-rsa, you can skip the ssh-keygen step.

To generate a new SSH key, use the following command:

ssh-keygen -t rsa -C "consxiong@123.com"

This command will prompt you for a location and filename to store the key pair and for a password. When prompted for the location and filename, just press enter to use the default. If you use a different name, the key will not be used automatically.

Note: It is a best practice to use a password for an SSH key, but it is not required and you can skip creating a password by pressing enter.

If you want to change the password of your key later, you can use the following command: ssh-keygen -p <keyname>

Use the command below to show your public key:

Windows Command Line:

type %userprofile%\.ssh\id_rsa.pub

GNU/Linux/Mac/PowerShell:

cat ~/.ssh/id_rsa.pub

Copy-paste the key to the 'My SSH Keys' section under the 'SSH' tab in your user profile. Please copy the complete key starting with ssh-rsa and ending with your username and host.

To copy your public key to the clipboard, use the code below. Depending on your OS you'll need to use a different command:

Windows Command Line:

type %userprofile%\.ssh\id_rsa.pub | clip

Windows PowerShell:

cat ~/.ssh/id_rsa.pub | clip

Mac:

pbcopy < ~/.ssh/id_rsa.pub

GNU/Linux (requires xclip):

xclip -sel clip < ~/.ssh/id_rsa.pub

 

 

》》》》》》》》》》  实操

 

git 客户端执行,passphrase 输入密码

ssh-keygen -t rsa -C "constxiong@123.com"

 

win7 cmd 查看秘钥

type C:\Users\dell\.ssh\id_rsa.pub

 

删除换行放到 gitlab 页面 add key

 

ConstXiong 备案号:苏ICP备16009629号-3