简体   繁体   English

bash上传github api bash curl上传密钥不起作用

[英]bash upload github api bash curl upload key doesn't work

Edit: I found this is a good answer, so this can probably be marked duplicate: https://stackoverflow.com/a/31214819/123594 编辑:我发现这是一个很好的答案,因此可以将其标记为重复: https : //stackoverflow.com/a/31214819/123594

I'm trying to upload a freshly generated deployment key to github via bash/ curl 我正在尝试通过bash / curl将新生成的部署密钥上传到github

Here's what I have: ($1 is my repo name, $2 is a suffix for my key name) 这是我的财产:($ 1是我的回购名称,$ 2是我的键名的后缀)

TOKEN=`cat /path/to/.github_token`
ssh-keygen -b 2048 -t rsa -f /path/to/key/id_rsa-www_$2 -q -N ""
KEY=`cat ~/projects/automatem/ansible/roles/accounts/templates/id_rsa-www_$2.pub`
echo $KEY
curl -u "myusername:$TOKEN" https://api.github.com/repos/jochendaum/$1/keys -d '{"name":"AUS1","key":"$KEY","read_only":true}'

As output I get: 作为输出,我得到:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3rVUbDbhhHCD2q00T29UJRbMqbDdXOq8qwUlY/gOtvzxCu20nQHvGXG4L2FLWffO8V5TQH+e5Ei0G2TDfbjgiYH/BBBEd+agkZf6VHfWmOTG93D55Sse6LoVJNgXu1RICM3zS0CPQ31b05UUIw6AFjesntIh8EoaeftSm99CCxgLT3bRkSWkfSAng6VD6EwT1od+RMXxqOMpyJv0BeJaOELjJM8AAIIbjrcPaprAG3OixtJoYdBnUyK14srdmUjKmnJMFcrlFRPphzTnpjXZAFVIK1j7+Mh9UnNIKE5nlBL5Y5YtUkyy7ixIM/dCfu9tAyxufKjGz23Ug111WTmzB jochen@autodesktop2

{

  "message": "Validation Failed",
  "errors": [
    {
      "resource": "PublicKey",
      "code": "custom",
      "field": "key",
      "message": "key is invalid. It must begin with 'ssh-ed25519', 'ssh-rsa', 'ssh-dss', 'ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp384', or 'ecdsa-sha2-nistp521'. Check that you're copying the public half of the key"
    }
  ],
  "documentation_url": "https://developer.github.com/v3/repos/keys/#create"
}

Its as if something is being cut off when the key is sent through curl 当通过curl发送密钥时,好像有东西被切断了

除了您似乎使用的奇怪路径外,Bash不会在单引号内扩展任何内容,但可能会掩盖您的一面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM