2017-02-19 40 views
0

編輯:我發現這是一個很好的答案,所以這大概可以重複標明:https://stackoverflow.com/a/31214819/123594慶典上傳的GitHub API的bash捲曲上傳鍵不起作用

我想上傳到新生成的部署關鍵通過慶典/捲曲

這裏GitHub的我有什麼:($ 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}' 

當輸出我得到:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC3rVUbDbhhHCD2q00T29UJRbMqbDdXOq8qwUlY/gOtvzxCu20nQHvGXG4L2FLWffO8V5TQH+e5Ei0G2TDfbjgiYH/BBBEd+agkZf6VHfWmOTG93D55Sse6LoVJNgXu1RICM3zS0CPQ31b05UUIw6AFjesntIh8EoaeftSm99CCxgLT3bRkSWkfSAng6VD6EwT1od+RMXxqOMpyJv0BeJaOELjJM8AAIIbjrcPaprAG3OixtJoYdBnUyK14srdmUjKmnJMFcrlFRPphzTnpjXZAFVIK1j7+Mh9UnNIKE5nlBL5Y5YtUkyy7ixIM/dCfu9tAyxufKjGz23Ug111WTmzB [email protected] 

{ 

    "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" 
} 

它彷彿有什麼東西被切斷時的關鍵是通過捲曲

+0

嘗試'回聲 '{ 「名」: 「AUS1」, 「關鍵」: 「$ KEY」, 「READ_ONLY」:真正}''看什麼看嫋嫋:KEY'文字上的'$。 –

回答

0

發送除此之外,你似乎使用了奇怪的路徑,但它可能只是壞掩蔽在你的身邊,猛砸不會擴大任何東西在單引號內。