ssh生成密钥命令及配置

记录一下使用ssh-keygen生成ssh密钥说明

1
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
1
ssh-keygen -t rsa -b 4096 -C "sxzhi799@gmail.com"

一路回车即可

1
cat ~/.ssh/id_rsa.pub

如果出现错误提示kex_exchange_identification: Connection closed by remote
解决方案: 编辑 ~/.ssh/config 文件(没有就新增)

1
2
3
4
5
Host github.com
    HostName ssh.github.com
    # ProxyCommand nc -X 5 -x 127.0.0.1:7890 %h %p ## 配置使用socks5代理连接
    User git
    Port 443