生成SSH密钥
# Linux
ssh-keygen -t rsa -C "[email protected]"
# 存放的路径在操作提示有
id_rsa
:私钥id_rsa.pub
:公钥
# Windows
# 扩展
# GitHub 设置 SSH
默认认为,已经上传公钥等操作
ssh -T [email protected]
# 拉取[email protected]:xxxxx
# ssh -T [email protected]
# git clone [email protected]:xxxxx 注意不是 https://github.com/NipGeihou/xxxx.git
# 指定密钥连接 SSH
方法一:
ssh -i /root/.ssh/id_rsa -T [email protected]
方法二:
vim /root/.ssh/config
Host gitee gitee.com
HostName gitee.com
IdentityFile /root/.ssh/id_rsa2
User root
配置模板:
点击查看
Host myshortname realname.example.com
HostName realname.example.com
IdentityFile ~/.ssh/realname_rsa # private key for realname 这个注释要去掉,否则会报错
User remoteusername
Host myother realname2.example.org
HostName realname2.example.org
IdentityFile ~/.ssh/realname2_rsa # different private key for realname2
User remoteusername
上次更新: 2023/06/10, 18:45:20