git config –global user.name “dracuka” //配置用戶名
git config –global user.email “[email protected]” //配置email
生成ssh key
使用命令 ssh-keygen -t rsa -C “[email protected]”//your_email是你的email,比如[email protected]
如果有提示一路enter下去,不用輸入啥信息。或者你也可以設置一個口令,每次clone或者push的時候需要輸入。
假如你用的root用戶,上面命令執行成功後會在目錄/root/.ssh/下面生成文件id_rsa.pub
wangdongwen@greenvm-w10921v:~$ sudo ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
85:89:7f:fa:cf:9c:f6:f9:3c:d9:ec:d9:7f:ba:e6:a4 [email protected]
The key's randomart image is:
+--[ RSA 2048]----+
| |
| . o |
| . o . |
| . . |
| S . |
| o |
| . ..o|
| . o.+.=*|
| .oE+**X|
+-----------------+
github上添加ssh key
在個人設置頁面(personal settings),點擊SSH and GPG Keys,添加一個ssh key,title名字隨便填,key文本框裏就複製步驟3中id_rsa.pub裏面的所有內容(記得是所有內容,包括那個郵件名)。
驗證ssh key是否設置成功
執行命令ssh -T [email protected]
如果提示access dennied就是沒設置成功
提示You’ve successfully authenticated, but GitHub does not provide shell access
Github create repo
git init
git add README.md
git commit -m "first commit"
git remote add origin [email protected]:dracuka/job.git //這裏的dracuka更換成自己的github用戶名
git push -u origin master
…or push an existing repository from the command line
git remote add origin [email protected]:dracuka/job.git git push -u origin master