跳到主要内容

配置不同的 SSH Key

长念
长念阅读约 3 分钟2 年前发布

为不同的站点配置不同的 SSH Key。

生成 SSH Key

ssh-keygen -t RSA -C 'my_email@email.com'

配置

新建 config 文件

在用户文件夹下的 .ssh 文件夹下 ~/.ssh 新建 config 文件。

Windows 平台下的具体路径为 C:\Users\用户名\.sshMac 平台下的具体路径为 /Users/用户名/.ssh

touch config
写入配置
# Gitee
Host gitee.com
Hostname gitee.com
User git
Port 22
IdentityFile ~/.ssh/id_rsa_gitee

# GitHub
Host github.com
Hostname github.com
User git
Port 22
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_github