美文网首页
SSH_KEY配置

SSH_KEY配置

作者: 专治齐天大圣 | 来源:发表于2016-04-05 19:01 被阅读37次

生成公钥

打开命令行终端输入ssh-keygen -t rsa -C “username@example.com”,接下来点击enter键即可(也可以输入密码)。

$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Creates a new ssh key, using the provided email as a label
# Generating public/private rsa key pair.
Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]  // 推荐使用默认地址
Enter passphrase (empty for no passphrase):

之后会提示想要存放公钥的文件位置及密码;文件位置不填的话就会默认为 /Users/you/.ssh/id_rsa



成功之后

Your identification has been saved in /Users/you/.ssh/id_rsa.
# Your public key has been saved in /Users/you/.ssh/id_rsa.pub.
# The key fingerprint is:
# 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

本地打开 id_rsa.pub 文件,其内容就是生成的公钥内容。

管理多个公钥

如果需要使用多个账户建议生成多个公钥,可以在.ssh/config文件中加上下边一段

Host git.coding.net
User xxxx@email.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/coding_rsa  // 生成的非默认地址的公钥存放点

相关文章

网友评论

      本文标题:SSH_KEY配置

      本文链接:https://www.haomeiwen.com/subject/gzvplttx.html