Github 为我们提供了 Desktop App 用于我们本地和GitHub上的Repository交互,但作为码农,
在黑乎乎的shell中用命令似乎更有黑客感,显得更有技术含量。
如何生成 SSH
- 首先查看
.ssh
目录
我们的目标是生成id_dsa.pub
, 如果你从未生成过,查看之后应该是这样的
$ cd ~/.ssh
$ ls
known_hosts
或者
$ cd ~/.ssh
$ ls
authorized_keys2 id_dsa known_hosts
config id_dsa.pub
- 使用神奇的
ssh-keygen
$ ssh-keygen -o
Generating public/private rsa key pair.
Enter file in which to save the key (/home/mac/.ssh/id_rsa):
Created directory '/home/mac/.ssh'.
Enter passphrase (empty for no passphrase): #可以直接按回车
Enter same passphrase again: #可以直接按回车
Your identification has been saved in /home/schacon/.ssh/id_rsa.
Your public key has been saved in /home/schacon/.ssh/id_rsa.pub.
The key fingerprint is:
d0:82:24:8e:d7:f1:bb:9b:33:53:96:93:49:da:9b:e3 schacon@mylaptop.local
- 查看我们生成的SSH
$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU
GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3
Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA
t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En
mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx
NrRFi9wrf+M7Q== schacon@mylaptop.local
-
在
Github
设置SSH
试着在Github上
clone
repository
➜ 0.Github git clone git@github.com:pizzaql/pizzaql.git
Cloning into 'pizzaql'...
Warning: Permanently added the RSA host key for IP address '13.229.188.59' to the list of known hosts.
remote: Enumerating objects: 40, done.
remote: Counting objects: 100% (40/40), done.
remote: Compressing objects: 100% (24/24), done.
Receiving objects: 16% (189/1181), 28.01 KiB | 7.00 KiB/s
- 大功告成