Centos7 SSH公钥生成及配置

作者: siediyer 分类: linux 发布时间: 2022-03-18 23:16

1.你可以按如下命令来生成 sshkey:

ssh-keygen -t rsa -C "xxxxx@xxxxx.com"

ssh-keygen -t ed25519 -C "6273302@qq.com"
cat ~/.ssh/id_ed25519.pub

2.按照提示完成三次回车,即可生成 ssh key。通过查看 ~/.ssh/id_rsa.pub 文件内容,获取到你的 public key

cat ~/.ssh/id_rsa.pub

3.复制生成后的 ssh key,添加到项目中。

4.添加后,在终端(Terminal)中输入

ssh -T git@gitee.com
sudo -u www ssh -T https://gitee.com/siediy/hahamiao.git
sudo chmod 600 /root/.ssh/config
cat /root/.ssh/id_ed25519.pub
git remote add origin git@codeup.aliyun.com:5ee87a6db88b559999eceda0/www.hahamiao.com.git

5.简单的设置

git config --global user.name "yourname"
git config --global user.email "youremail@youremail.com"

6.Git的config

# codeup.aliyun.com
Host codeup.aliyun.com:5ee87a6db88b559999eceda0/www.hahamiao.com.git
    HostName codeup.aliyun.com:5ee87a6db88b559999eceda0/www.hahamiao.com.git
    PreferredAuthentications publickey
    IdentityFile /root/.ssh/id_ed25519
    IdentitiesOnly yes

7.Vhost

vim /etc/hosts

::1     localhost       localhost.localdomain   localhost6      localhost6.localdomain6
127.0.0.1       localhost       localhost.localdomain   localhost4      localhost4.localdomain4

118.31.165.50   codeup.aliyun.com:5ee87a6db88b559999eceda0/www.hahamiao.com.git

 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

Title - Artist
0:00