2021年08月21日

ssh方式访问github

github限制使用http方式push后,改为用ssh方式。ssh比http的push速度快多了。

查看repo的origin。

[albert@MacBookAir /Users/albert/.emacs.d]
$git remote -v
origin  https://github.com/georgealbert/.emacs.d.git (fetch)
origin  https://github.com/georgealbert/.emacs.d.git (push)

修改push的url,使用ssh方式。

[albert@MacBookAir /Users/albert/.emacs.d]
$git remote set-url --push origin git@github.com:georgealbert/.emacs.d.git 
[albert@MacBookAir /Users/albert/.emacs.d]
$git remote -v                                                             
origin  https://github.com/georgealbert/.emacs.d.git (fetch)
origin  git@github.com:georgealbert/.emacs.d.git (push)
[albert@MacBookAir /Users/albert/.emacs.d]
$git push -v origin master
Pushing to git@github.com:georgealbert/.emacs.d.git
The authenticity of host 'github.com (20.205.243.166)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,20.205.243.166' (RSA) to the list of known hosts.
Enumerating objects: 39, done.
Counting objects: 100% (39/39), done.
Delta compression using up to 8 threads
Compressing objects: 100% (34/34), done.
Writing objects: 100% (34/34), 8.66 KiB | 1.73 MiB/s, done.
Total 34 (delta 22), reused 0 (delta 0)
remote: Resolving deltas: 100% (22/22), completed with 5 local objects.
To github.com:georgealbert/.emacs.d.git
   1ba5121..3a78277  master -> master
updating local tracking ref 'refs/remotes/origin/master'