Linux笔记 #06# 在VPS上自建Git服务
参考:
GitHub Help: Connecting to GitHub with SSH
1. 安装记录(可能有错。。。)
本地( Debian 8.8):
sudo apt-get install git git version # 确保正确安装
root@xkfx:~# git config --global user.name "little fish"
root@xkfx:~# git config --global user.email "little_fish@163.com"
# 初始设置,作为储存在本地的变量,会用在Git的提交日志中
root@xkfx:~# git config user.name
little fish
root@xkfx:~# git config user.email
little_fish@.com
生成 ssh key (这个不是 git 命令!),
root@xkfx:~# ssh-keygen -t rsa -C "little_fish@163.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
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:
:f3:c5::::3f:::fc::c7:df:4c:9c: little_fish_pubic@gmail.com # 已改,仅作示范
The key's randomart image is:
+---[RSA ]----+
| .*..+o..E...|
| o.++ +o .o|
| .oo + +. + |
| ..o = . o|
| S . |
| . |
| |
| |
| |
+-----------------+
总之本地持有私匙,远程持有对应公匙,这样双方才能安全通信。关于邮箱参数有啥用可以参考这个文档(是作为 ssh key 的一个标签,这在仓库放在 github 上的时候会有用 ~)密码是给私匙配的。
VPS(Centos 6 x86 bbr ):
[root@xkfx ~]# yum install git
[root@xkfx ~]# git version
把有权限访问的【终端的公匙】拷贝进去,一行一个,
root@xkfx:~# cat /root/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDGetaJDc9kTMrRlw+++ve+w4gamJH2LfNC9qJa/LbvXUFkO1atJCQxn2DlaNvQxrMvSSAHRNo2MmNnxRp9Vi8sg6KawgVKx6n60maMxvMugkzV+BOm8ds+C5M+JAdRzjBzfdgWIMgdqZfyfG1sHnTg6JGvzCxJ9DigNb+2cho20CXhCv5JKsn2fHzyc75BguT8gxZ7e9vtQNWywLNNse8mCFmc28kmxXo14eDuZPbDGnEU12BO+UFVqYbeFVNLVcS8x2GiJg/Iy5pDCPScPI0iyZGor7AkI0SjfhQuc4uMDVIDWC5gp8cqudxP little_fish_pubic@gmail.com
[root@xkfx ~]# sudo adduser git
[root@xkfx ~]# cd /home/git
[root@xkfx git]# mkdir .ssh
[root@xkfx git]# vim /home/git/.ssh/authorized_keys
[root@xkfx git]# sudo git init --bare sample.git
Initialized empty Git repository in /home/git/sample.git/
出于安全性考虑,
[root@xkfx git]# sudo chown -R git:git sample.git
[root@xkfx git]# vim /etc/passwd

2.基本操作尝试
root@xkfx:~# git clone git@your ip address:/home/git/sample.git
Cloning into 'sample'...
ssh: connect to host your ip address port 22: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
---------------------------------------------------------------------------------------
root@xkfx:~# eval $(ssh-agent -s)
Agent pid 16083
root@xkfx:~# ssh-add ~/.ssh/id_rsa
Enter passphrase for /root/.ssh/id_rsa:
Bad passphrase, try again for /root/.ssh/id_rsa:
Identity added: /root/.ssh/id_rsa (/root/.ssh/id_rsa)
root@xkfx:~# ssh -T git@your ip address
ssh: connect to host your ip address port 22: Connection refused
---------------------------------------------------------------------------------------
root@xkfx:~# ssh -T git@github.com
The authenticity of host 'github.com (192.30.253.112)' 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)? yes
Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Permission denied (publickey).
---------------------------------------------------------------------------------------
换菜鸟教程从头敲一遍 失败
换了个 VPS 按照菜鸟教程重敲了一遍 就成功了。
root@xkfx:~# groupadd git
root@xkfx:~# useradd git -g git
root@xkfx:~# cd /home/git/
root@xkfx:/home/git# mkdir .ssh
root@xkfx:/home/git# chmod .ssh
root@xkfx:/home/git# touch .ssh/authorized_keys
root@xkfx:/home/git# chmod .ssh/authorized_keys
root@xkfx:/home/git# cd /home
root@xkfx:/home# mkdir gitrepo
root@xkfx:/home# chown git:git gitrepo/
root@xkfx:/home# cd gitrepo
root@xkfx:/home/gitrepo# git init --bare runoob.git
Initialized empty Git repository in /home/gitrepo/runoob.git/
root@xkfx:/home/gitrepo# chown -R git:git runoob.git # 必要的!否则会因为权限不够无法 push
root@xkfx:/home/gitrepo# vim /home/git/.ssh/authorized_keys
mdzz@LAPTOP-QGECNCGO MINGW64 /d/labs
$ git clone git@????????????:/home/gitrepo/runoob.git
Cloning into 'runoob'...
warning: You appear to have cloned an empty repository.
3. 应用
存放不愿公开的项目
作为网盘方便地保存重要文件
例如打算写个小项目:
在 VPS 上建立仓库,无论你在本地是否已经开始写(写了就 移花接木 :D)
VPS:
root@xkfx:/home/gitrepo# git init --bare mangast.git
root@xkfx:/home/gitrepo# chown -R git:git mangast.git
本地:
$ git clone git@????????????:/home/gitrepo/mangast.git
--------- 移 花 接 木 ------
$ git add sql/ src/ web/
$ git commit -m "basis."
$ git push origin master
Linux笔记 #06# 在VPS上自建Git服务的更多相关文章
- 自建Git服务Gogs和CI/CD服务Drone
自建Git服务Gogs和CI/CD服务Drone 项目:https://gogs.io Gogs运行 docker run -d --name=gogs -p 10022:22 -p 10088:30 ...
- golang 2行代码在基于arm linux的树莓派、orangepi上运行http web服务
go语言(golang)简化了跨平台交叉编译步骤,支持在windows系统下交叉编译基于arm+linux平台的应用,运行时无需其它依赖库.以下以一个简单的http server为例,先上源码: ** ...
- Git学习笔记(四)标签和搭建Git服务
一.标签是什么 发布一个版本时,我们通常先在版本库中打一个标签,这样,就唯一确定了打标签时刻的版本.将来无论什么时候,取某个标签的版本,就是把那个打标签的时刻的历史版本取出来.所以,标签也是版本库的一 ...
- Linux 笔记 #03# 在 Debian远程服务器上运行 Java socket程序
我试图做什么:把我的破代码放到服务器上运行,并成功与客户端进行 socket通信. 预备环境:刚安装好 MySQL 和 JVM 的 Linux远程服务器(Debian 8)一台. 主要有如下几个步骤: ...
- 在vps上安装 kali linux
在渗透测试过程中,很多时候我们需要反弹一个shell回来.使用empire也好,MSF也好,其他工具也好,都避不开公网IP的问题.这时候我们就需要一个VPS来进一步进行渗透测试. 建立通道连接的方式有 ...
- 如何在LINUX VPS上安装VPN详细步骤
在vps上安装vpn是个难点,很多朋友都不会,这儿结合一位朋友的安装经验做下介绍.注意你的vps要安装做vpn使用,一定要注意你的流量限制,使用Vpn上游戏上youtube看视频等都比较耗费资源,否则 ...
- 使用 Linux 终端 SSH 登录 VPS
Windows 中远程 SSH 登录 VPS 进行管理的利器是 PuTTY,但是 Linux 中就没必要用它了.Linux.Unix(包括 Mac iOS)都必然有内置的命令行终端,内建了 OpenS ...
- 在VPS上安裝BT軟體Transmission
在VPS上安裝BT軟體Transmission 作者: 窮苦人家的小孩 | 2009-12-04 55 Comments VPS 還能怎玩?! 裝Proxy,裝VPN,這還不夠,我還用來掛種子 ...
- VPS上拖文件(Apache配置、SSH)
场景 下载VPS上的文件 命令 Apache配置 yum install httpd -y /etc/rc.d/init.d/httpd start /sbin/iptables -I INPUT - ...
随机推荐
- AndroidのListView之滑动列表项(点击事件和滑动事件共存)
这里正好在项目有这么一个bt的需求,如下图ListView的item可以响应点击事件也可以响应item的左右滑动事件,两个事件可以相互独立互不影响. 听说iphone的list选项就有这样bt的功能, ...
- c++中new/operator new/placement new
1. new/delete c++中的new(和对应的delete)是对堆内存进行申请和释放,且两个都不能被重载. 2. operator new/operator delete c++中如果想要实现 ...
- synchronized同步语句块
用关键字synchronized声明方法在某些情况下是有弊端的,比如A线程调用同步方法执行一个长时间的任务,那么B线程则必须等待比较长时间.在这样的情况下可以使用synchronized同步语句块来解 ...
- jQuery的无new构建
正常面向对象的写法: var cJquery = function(){ //构造函数体 }; cJquery.prototype = { name : function(alert("ch ...
- 2015.10.9js(页面坐标)
关于js鼠标事件综合各大浏览器能获取到坐标的属性 1.page随滚动条变化(pageY会增加滚动条滚动的距离),兼容性:除IE6/7/8不支持外,其余浏览器均支持; 2.clientX/Y获取到的是触 ...
- 解决在微信中部分IOS不能自动播放背景音乐
前言在做各种HTML5场景页面的时候,插入背景音乐是一个很普遍的需求.我们都知道,IOS下的safari是无法自动播放音乐的,以至一直以来造成一种错误的认识,iso是无法自动播放媒体资源的.直到微信火 ...
- 【BZOJ2661】[BeiJing wc2012]连连看 最大费用流
[BZOJ2661][BeiJing wc2012]连连看 Description 凡是考智商的题里面总会有这么一种消除游戏.不过现在面对的这关连连看可不是QQ游戏里那种考眼力的游戏.我们的规则是,给 ...
- linux漏洞扫描工具【lynis】
Lynis是一款Unix系统的安全审计以及加固工具,能够进行深层次的安全扫描,其目的是检测潜在的时间并对未来的系统加固提供建议.这款软件会扫描一般系统信息,脆弱软件包以及潜在的错误配置. 特征: 漏洞 ...
- 删除Linux的用户
vipw : root@ www.linuxidc.com :/home# vipw 找到你之前创建的用户,用dd删除那行(记得保存:wq or :x)..之后. root@ www.linuxidc ...
- 洛谷P3809 后缀排序【后缀数组】【模板】
题目背景 这是一道模板题. 题目描述 读入一个长度为 nn 的由大小写英文字母或数字组成的字符串,请把这个字符串的所有非空后缀按字典序从小到大排序,然后按顺序输出后缀的第一个字符在原串中的位置.位置编 ...