I have finally discovered a solution to the problem. As it was described here, I ran the following command in the terminal:
unset SSH_ASKPASS
and then running git push origin master works the way it should. You can also add the line to your .bashrc file.