Git - Using SSH key to push code without entering password

I had to enter password every time I push my commits to git server. I can avoid doing it again and again by using SSH key:

1. In my computer, generate SSH Key:

$ cd ~/.ssh
$ ssh-keygen -t rsa -C ""

The above command will create 2 files, id_rsa and is your public key. Send it to the git server.

2. Copy the public key to the remote server:

$ ssh-copy-id -i ~/.ssh/ myusername@remotehost

The command will prompt me to enter password of my user account in the remotehost. Enter and done.

+ After that, if I can ssh to the remote server without error, I can assume that it works:

trinh@mylocalpc$ ssh myusername@remotehost

+ If I get the error "Agent admitted failure to sign using the key", run the following command and try to ssh again:

$ ssh-add

From now on, whenever I push code to remote git server, I don't have to input my password anymore.