我一直在编写bash脚本来使用SSH克隆私有Github存储库。需要遵循步骤-
如何在bash脚本中自动化步骤3。任何帮助都将不胜感激。
您需要使用GitHub API POST/user/keys向经过身份验证的用户的GitHub帐户添加公共SSH密钥。
它要求您通过基本身份验证或至少具有write:public\u密钥作用域的OAuth进行身份验证。
因此,脚本必须作为参数。
结果:示例
# Add a SSH-Key (type "user:passwd ^D"), output: JSON object, or JSON error
curl -X POST -u <user[:passwd]> https://api.github.com/user/keys \
--data "{\"title\": \"<title>\", \"key\": \"$(cat $HOME/.ssh/id_rsa.pub)\"}"
(此处为其他示例)