mac使用git管理Github以及生成 SSH 公鑰
現在開始設定Mac管理Github,有一點需要知道的是本地的git倉庫和Github伺服器之間是通過ssh加密的。
在終端執行
?1 2 3 4 5 6 7 8 9 10 |
ozil:tmp
mesut$ ssh -v
OpenSSH_6.2p2,
OSSLShim 0.9 .8r
8
Dec 2011
usage:
ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
[-D
[bind_address:]port] [-e escape_char] [-F configfile] [-I
pkcs11] [-i identity_file]
[-L
[bind_address:]port:host:hostport]
[-l
login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
[-R
[bind_address:]port:host:hostport] [-S ctl_path]
[-W
host:port] [-w local_tun[:remote_tun]]
[[email protected]]hostname
[command] |
明顯Mac已經安裝了ssh。
1:建立SSH Key
?1 2 3 4 5 6 |
ozil:tmp
mesut$ cd ~
ozil:~
mesut$ pwd
/Users/mesut
ozil:~
mesut$ cd .ssh
-bash:
cd: .ssh: No such file or directory
ozil:~
mesut$
|
進入當前的使用者目錄,波浪線表示的是當前目錄。判斷是否已經安裝了.ssh,避免預設安裝會覆蓋之前安裝的。明顯當前目錄沒有該檔案
執行建立 ssh key
?1 |
ssh-keygen
-t rsa -C youremail @example .com(你的Github登陸名)
|
接著都是回車,選擇預設的目錄,預設的密碼即可
?1 2 3 4 5 6 7 |
Generating
public / private
rsa key pair.
Enter
file in which to save the key (/Users/mesut/.ssh/id_rsa):
|