I am working on a script that creates ssh keys and puts them into github using bash. I am running into this error when running this function.. I want a way to generate ssh keys and put them into github from terminal within my script.
sudo ssh-keygen -t rsa
KEY=$(sudo cat ~/.ssh/id_rsa.pub)
echo "Here is your KEY var: ${KEY}"
read -p "GitHub Username: " USERNAME
read -p "Please enter a title for you ssh key: " TITLE
curl --user "\"${USERNAME}"\" -X POST --data '{ "\"title"\": "\"$TITLE"\", "\"key"\": "\"$KEY"\" }' https://api.github.com/user/keys
Error: { "message": "Bad credentials", "documentation_url": "https://developer.github.com/v3" }
ssh-keygenas root?sudois not a magic "make everything work" command. For every command that can be written with sudo, there is a better approach without it.