在 github 操作中使用 ssh 密钥文件
1. Github 中的配置
添加 SSH Key。如下图所示。输入 title。将你的公钥的内容拷贝到 Key 部分:

点击 Add SSH Key 按钮,该密钥就添加好了。

2. git 配置
创建 ~/.ssh/config 文件,内容如下。其中 sammyliu.pri 文件为上面公钥对应的私钥文件。
sammyliush@raspberrypi:~/gitdir/aws-iot-with-respberrypi$ cat ~/.ssh/config host github.com HostName github.com IdentityFile ~/.ssh/sammyliu.pri User git
进行 git 操作,git push 时就不需要输入密码了。
git clone git@github.com:sammyliush/aws-iot-with-respberrypi.git git add publish2awsiot.py git commit -m "Add python code to publish data of DHT22 sensor on RaspberryPi to AWS IoT Core" git push
顺便复习一下 SSH 密钥认证原理:

参考链接:

浙公网安备 33010602011771号