window下 配置gitlab ssh非端口22端口

git config --global user.name "jack"
git config --global user.email "jackluo@xxx.com"
Create a new repository
mkdir fromai_cn
cd fromai_cn
git init
touch README.md
git add README.md
git commit -m "first commit"
git remote add origin git@git.xxx.cn:develper/xxx_cn.git
git push -u origin master
Push an existing Git repository
cd existing_git_repo
git remote add origin git@git.xxxx.cn:develper/xxx_cn.git
git push -u origin master

这个是gitlab上面的配置 

window 下安装 git 的客户端,全是google的地址这里提供一个 http://pan.baidu.com/s/1i3ACfe1

安装好后,因为 服务器的端口ssh不是22号所以

先来配置 ssh自动登陆

ssh-keygen -t rsa -C jackluo@xxxx.com

修改方法,修改当前用户的home下的.ssh/config文件

vim ~/.ssh/config

host example
hostname example.com
port 1234
修改项目文件下的 .git/config 文件:
[core]
    repositoryformatversion = 0
    filemode = false
    bare = false
    logallrefupdates = true
    symlinks = false
    ignorecase = true
    hideDotFiles = dotGitOnly
[remote "origin"]
    url = git@example:develper/xxxx_cn.git
    fetch = +refs/heads/*:refs/remotes/origin/*

最后把公钥添加到gitlab中

$ cat ~/.ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA1B0//oNYOKn6/SS2XyuMmCbys9bNlfuYvhLUYa9K989JuhSHhtnacCu+FdnL3XGQBrtFykjR+yHW3bNqqLa+oYJc12HOpTcgKLwWLROuy/5DLOaYatOxk0J4hk91zHINQKfcx0j/1aIFY9CZJWhdaUx48dhcIqSqskQrpaVC/uONliT5Xphr0HjdSI0wBLFPhTJrlzWOyA8FCvWDc93BydhJk3pwscFCaLH/69oi1BQQe+weweweXMsNv21+4kI5TDmDcgO5gagFyoq38TR2JM9khp1RO+5ekR/TW1qo9z1WJj6Phb9dazfL2wNaIGgfG1RNb0iNTQoGH+cOWBoL3/+jbQ== jackluo@xxxx.com
把这个复制 到 gitlab

My SSH keys 中

 
 

 

git push origin master

 ========================================================================

2. 生成ssh key时同时指定保存的文件名

ssh-keygen -t rsa -f ~/.ssh/id_rsa.sohu -C "email" 

上面的id_rsa.sohu就是我们指定的文件名,这时~/.ssh目录下会多出id_rsa.sohuid_rsa.sohu.pub两个文件,id_rsa.sohu.pub里保存的就是我们要使用的key。

HOST fromai
    hostname xxxxx
    IdentityFile /home/jackluo/.ssh/id_rsa.fromai
    port 2222

 

3. 新增并配置config文件

添加config文件

如果config文件不存在,先添加;存在则直接修改

touch ~/.ssh/config
config文件里添加如下内容(User表示你的用户名)
Host *.cloudscape.sohu.com
    IdentityFile ~/.ssh/id_rsa.sohu User test
==============================================================================================
#Default Git
Host defaultgit
   HostName IP Address #域名也可
   User think
   IdentityFile ~/. ssh /id_rsa
 
#Second Git
Host secondgit
   HostName IP Address #域名也可
   User think
   IdentityFile ~/. ssh /id_rsa_second
 =========================================================

Bad owner or permissions on $HOME/.ssh/config

The ssh with RHEL 4 is a lot more anal about security checking. In my case, it was the fact that $HOME/.ssh/config was group-writable which was causing it to barf. To fix:

$ cd ~/.ssh
$ chmod 600 *
 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值