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.
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 *
 
目录
相关文章
|
27天前
|
消息中间件 安全 Unix
SSH配置多台服务器之间的免密登陆以及登陆别名
SSH配置多台服务器之间的免密登陆以及登陆别名
36 1
|
29天前
|
网络安全
检查使用IP协议远程维护的设备是否配置SSH协议,禁用telnet协议
检查使用IP协议远程维护的设备是否配置SSH协议,禁用telnet协议
12 0
|
2天前
|
存储 JSON Java
gitlab配置hook,commit message的时候校验提交的信息
gitlab配置hook,commit message的时候校验提交的信息
11 0
|
3天前
|
安全 Linux 网络安全
|
9天前
|
Ubuntu 网络安全 数据安全/隐私保护
使用SSH隧道将Ubuntu云服务器Jupyter Notebook端口映射到本地
这样,你就成功地将Ubuntu云服务器上的Jupyter Notebook端口映射到本地,使你能够通过本地浏览器访问并使用Jupyter Notebook。
30 1
|
20天前
|
Linux 网络安全 开发工具
【GitLab私有仓库】在Linux上用Gitlab搭建自己的私有库并配置cpolar内网穿透
【GitLab私有仓库】在Linux上用Gitlab搭建自己的私有库并配置cpolar内网穿透
|
22天前
|
网络协议 安全 Shell
配置ssh服务
配置ssh服务
|
1月前
|
Shell 网络安全 开发工具
配置SSH时候,Permission denied问题解决方法
配置SSH时候,Permission denied问题解决方法
40 4
|
1月前
|
Shell 网络安全 开发工具
GitLab创建项目的时候需要SSH Keys
GitLab创建项目的时候需要SSH Keys
8 0
|
2月前
|
Devops 开发工具 数据安全/隐私保护
Docker Swarm总结+CI/CD Devops、gitlab、sonarqube以及harbor的安装集成配置(3/5)
Docker Swarm总结+CI/CD Devops、gitlab、sonarqube以及harbor的安装集成配置(3/5)
74 0