生成SSH密钥
ed25519 密钥(推荐)
关于 ed25519
与 rsa
的区别,参考:Enhance Security of your SSH Keys with ed25519 Algorithm (opens new window)
ssh-keygen -m PEM -t ed25519 -C "[email protected]"
~/.ssh/id_ed25519
:私钥~/.ssh/id_ed25519.pub
:公钥
RSA 密钥(弃用)
ssh-keygen -t rsa -C "[email protected]"
# 存放的路径在操作提示有
id_rsa
:私钥id_rsa.pub
:公钥
# 扩展
# 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/12/05, 09:33:37