mac生成SSH证书且修改host

生成SSH

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:

cat ~/.ssh/id_rsa.pub

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

ssh-keygen -t rsa -C "[email protected]"

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.

Use the command below to show your public key:

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:

pbcopy < ~/.ssh/id_rsa.pub

修改Host

1、打开命令终端,输入下面的命令,进入hosts文件:

sudo vim /etc/hosts
  • 输入电脑登录密码后,会出现如下界面:


    image.png
  • 按下键盘的 i 字母键,进入编辑模式,然后将光标移到最末端,另起一行可以新添加一个,如下图:


    image.png
  • 添加完毕之后,按下键盘的 Esc 键,退出编辑模式,然后输入 :wq ,保存并退出。 输入 :wq! 为强制保存

  • 按下Enter键盘,添加成功。

2、查看host

more /etc/hosts
  • 就能看的你刚才添加的host啦.

查看本地ssh 的方法
终端输入:

cd ~/.ssh
open .

就能看到你的私人秘钥了

  • 遇到SSL问题的解决方法:
git config --global http.sslVerify false

参考文章 https://confluence.atlassian.com/bamkb/ssl-certificate-subject-305037865.html

你可能感兴趣的:(mac生成SSH证书且修改host)