之前一直用https来push到github上, 今天试了下用ssh, 把origin改为ssh地址后, 用git push -u origin master出现错误:
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
上网搜了一下, 原因是' You've probably not added a public key to your SSH keys.'
解决方法如下:
用下面的命令生成public key
$ ssh-keygen -t rsa
复制 public key (id_rsa.pub
) 到你账户的 list of SSH keys, 再重新push.
参考:
http://stackoverflow.com/questions/14967621/fatal-the-remote-end-hung-up-unexpectedly