0

我需要在我的 cPanel WHM VPS 上设置一个 git 服务器,生成一个 URL 以连接到一个仓库(我在 /opt/git/repo.git 上创建了一个仓库并配置了 SourceTree 或任何其他 Windows 可视 Git 客户端。

我遵循了本指南:https ://newagesoldier.com/setting-git-cpanel-server/ 并设置了我的仓库。

然后我尝试通过在我的 Windows 控制台上运行此命令来克隆它:

git clone git@server.domain.com/opt/git/repository.git

但收到此错误:

致命:存储库“[URL]”不存在

我已经阅读了很多关于这个案例的帖子和问题,但很多都是很老的,还有一些不是很清楚就是不完整。

谢谢!

4

1 回答 1

1

如何在 windows 和 cpanel linux 帐户之间使用 ssh 进行 git push/pull。

*服务器:Linux:centos/whm/cpanel/ssh 账号

开发:Windows7 x64:使用 C:/cygwin (2016)、putty (2015)、

[Windows]
> puttygen
  generate and save to ~/.ssh/myprivatekey.ppk
    > save as openssh > myopenssh.key
    > Copy public key mypublickey.txt

[Cpanel]
  Allow ssh access
  Paste mypublickey.txt into cpanel ssh keys,
    Authorize key.

[Check SSH key works]
> ssh -V
  ..2016..
> c:/cygwin/bin/rsync --list-only \
    -e "ssh -i myopenssh.key" \
    "USERNAME@website.org:/home/USERNAME"
  SUCCESS

[Linux]
> putty USERNAME@website.org
  using above myprivatekey.ppk
$ pwd
  /home/USERNAME
$ hostname
  website.org
# Setup git repo on linux
$ git --version  # 1.7... yum update...on linux if you need a new git.    
$ alias git="/usr/local/cpanel/3rdparty/bin/git"    
$ git --version # 2.8...        
$ mkdir ~/repo.git ; cd ~/repo.git ; git init --bare    
  Initialized empty Git repository in /home/USERNAME/repo.git/
$ git config --global user.name "USERNAME"
$ git config --global user.email USERNAME@website.org
$ cd ~ ; git init; git remote add repo repo.git     
$ git add public_html
$ git commit -m "first commit"
$ git push repo master
   SUCCESS

[Windows]
:: **Now clone CPANEL account into xampp**
> cd c:/xampp/htdocs/WEBSITE
> git --version # 2.8...
> git init
> git remote add origin ssh://USERNAME@website.org/home/USERNAME/repo.git
> git pull
  Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
> git config core.sshCommand "ssh -i path/to/openssh.key" 
:: Dont use doublequotes in the next command
> set GIT_SSH_COMMAND=ssh -i path/to/myopenssh.key   
> git pull
  SUCCESS 
:: .. edit .. commit 
> git push
  SUCCESS

windows/cmd/cygwin 的可选设置

> set HOME=c:/users/%USERNAME%
> setx HOME %HOME% -m
> cd /d %HOME%
> mkdir .ssh
:: OR create a hardlink to your .ssh dir
> mklink /D c:/your/.ssh .ssh
> ls -al ~/.ssh/

如果 windows cygwin64/ssh 抱怨 ~/.ssh/config 上的权限不正确,请使用此标志 -F ..

> set  GIT_SSH_COMMAND=ssh -F ~/.ssh/config -i path/to/myopenssh.key   
> setx GIT_SSH_COMMAND "ssh -F ~/.ssh/config -i path/to/myopenssh.key" -m
> ssh -F ~/.ssh/config -i path/to/myopenssh.key  
于 2016-08-28T12:47:08.987 回答