Saturday, February 26, 2022

[SOLVED] how to automate to pass answer to commad line

Issue

Trying to automate my github authentication whenever I run git push it asks me for username and authentication enter image description here

I want to automate it throw script so that whenever it asks for username my script will pass it NOTE: even git push command is automated through script

Here is how I automates git push using script

read -p "Do you want to push changes? (y/n)" push_choice 
if [ "$push_choice" == "y" ];
then
git push

its more than this but after code hit git push command it asks me for password and username.

So is there any way that this script will pass all the information it needed because everytime it asks for same username and pass


Solution

Use SSH with public key authentication instead of password.

See e.g. https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh



Answered By - Bodo
Answer Checked By - Dawn Plyler (WPSolving Volunteer)