Search code examples
githubssh-keys

Push to GitHub without a password using ssh-key


I generated an SSH key pair without a password and added the public key to GitHub.

Connection with

user@dev:/var/www/project# ssh -T git@github.com
Hi User! You've successfully authenticated, but GitHub does not provide shell access.

was successful and when I rename the key, it fails.

But when I want to push my changes, it stills ask me for my username and password combination.

Is there a way to push without a password?


Solution

  • If it is asking you for a username and password, your origin remote is pointing at the HTTPS URL rather than the SSH URL.

    Change it to ssh.

    For example, a GitHub project like Git will have an HTTPS URL:

    https://github.com/<Username>/<Project>.git
    

    And the SSH one:

    git@github.com:<Username>/<Project>.git
    

    You can do:

    git remote set-url origin git@github.com:<Username>/<Project>.git
    

    to change the URL.