准备:服务器 插入git 命令:apt install git
客户端:安装git 后打开命令行配置git用户和邮箱命令如下$git config --global user.name "John Doe"
$git config --global user.email johndoe@example.com
一、(服务器)git init --bare /root/git/sample.git 创建仓库
二 (服务器,为了不输入密码)编辑文件vi /etc/ssh/sshd_config
松开注释 PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
重启ssh 命令: service sshd restart
三、(客户端,可做可不做)设置SSH Key
打开 Git GUI界面有个帮助->show SSH Key菜单,创建密钥.生产密钥位置通常情况下windows在 C盘用户 .ssh文件夹下
打开id_rsa.pub文件复制内容
(服务器端)在root根目录下 新建.ssh文件夹.新建authorized_keys文件,将id_rsa.pub文件中的内容复制到此处保存.
四 '克隆
git clone ssh://用户@服务器地址:端口/root/git/sample.git