如何在linux环境下搭建github环境

时间:2022-01-07 22:11:26

首先安装github

# yum install git

完成之后

https://help.github.com/articles/generating-ssh-keys/#platform-linux  官方设置教程在这个网址下

我来说明一下我的配置

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

运行这段代码   your_email@example.com  就是你自己的github邮箱。。。不要问我github怎么注册。。。百度一下。

提示:

Generating public/private rsa key pair.

出现:

Enter file in which to save the key (/Users/you/.ssh/id_rsa): [Press enter]

按回车

Enter passphrase (empty for no passphrase): [Type a passphrase] # Enter same passphrase again: [Type passphrase again]

输入两次密码,用来后面获取sshkey

提示:

Your identification has been saved in /Users/you/.ssh/id_rsa. # Your public key has been saved in /Users/you/.ssh/id_rsa.pub. # The key fingerprint is: # 01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your_email@example.com

运行:

eval "$(ssh-agent -s)" # Agent pid 59566

绿色是成功的提示

再运行

ssh-add ~/.ssh/id_rsa

到了下一步就跟官方说的不一样,因为辣个xclip小哥我没装(也没装好,缺个X11什么的。。。以后装好了再跟大家说)

运行:

cat ~/.ssh/id_rsa.pub

会拿到一段ssh-rsa 开头 your_email@example.com  结尾的key

然后拿到这段key

登陆github的网站去添加,这段教程在官网中有截图,在setting 的 SSH keys里Add  ,会发帖的都会。

添加成功以后

运行:

ssh -T git@github.com

检测是否链接上

看到下面两个代码出现,你就超神一般的搞定了

The authenticity of host 'github.com (207.97.227.239)' can't be established. # RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48. # Are you sure you want to continue connecting (yes/no)?
# Hi username! You've successfully authenticated, but GitHub does not # provide shell access.

关于怎么把项目拉下来

cd 到存放文件的目录下

运行

git clone https://github.com/git用户名/要克隆的文件

如果在你的目录下出现了文件夹里面还有一个index.php的文件就ok了