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
修改项目文件下的 .git/config 文件:
[core]
repositoryformatversion =
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

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 *
 

window下 配置gitlab ssh非端口22端口的更多相关文章

  1. window下配置SSH连接GitHub、GitHub配置ssh key

    window下配置SSH连接GitHub.GitHub配置ssh key   此经验分两部分: 第一部分介绍:在windows下通过msysGit(Git for windows.Git Bash)配 ...

  2. ssh-copy-id使用非默认22端口

    ssh-copy-id使用及非默认22端口时报错 ssh-copy-id使用介绍 说明:ssh-copy-id命令可以把本地的ssh公钥文件安装到远程主机对应的账户下. 功能:ssh-copy-id ...

  3. centos 7.0 修改ssh默认连接22端口 和 添加防火墙firewalld 通过端口

    首先 先做的就是 修改ssh的默认端口22 需要修改文件 /etc/ssh/sshd_config 使用命令 vi /etc/ssh/sshd_config [root@localhost ~]# v ...

  4. window 下配置wamp 环境

    PHP下载 下载php压缩包,几点注意:这里我安装的事apache 所以在 php官方下载页时不是随便下载的,不然可能配置不了apache! 注意我以下图片标注

  5. Window下配置NodeJs环境详解

        今年打算学习Web这块,所以就买了本Node.js+MongoDb+AngularJS这本书,这周天也比较忙,想着录视频(拍小片,不是AV,不要误会,是在线课程)的事情,这周又将Asp.Net ...

  6. linux ssh修改 默认22端口

    修改ssh 配置  /etc/ssh/sshd_config service sshd restart

  7. window下配置SSH连接GitHub、GitHub配置ssh key(转)

    转自:http://jingyan.baidu.com/article/a65957f4e91ccf24e77f9b11.html 此经验分两部分: 第一部分介绍:在windows下通过msysGit ...

  8. window下配置ssh key

    在windows下通过msysGit(Git for windows.Git Bash)配置SSH Keys连接GitHub. 1.检查本机是否有ssh key设置 $ cd ~/.ssh 或cd . ...

  9. ssh 和 scp 命令访问非默认22端口。

    ssh :(命令中的 p 小写) ssh -p 端口号 root@服务器ip scp: (命令中的 P 大写)(-r表示将目录下的目录递归拷贝.“.*”是将所有文件包括隐藏文件.) 上传文件到服务器s ...

随机推荐

  1. document.location.reload();与location.href='xxx'的区别

    document.location.reload();会重新加载页面,onload事件会被触发. location.href='xxx'刷新页面,onload事件不会触发.

  2. html5 离线存储 worker

    html5 离线存储 <!DOCTYPE html> <html manifest="cache.manifest"> <!--manifest存储- ...

  3. hdu 4045 2011北京赛区网络赛F 组合数+斯特林数 ***

    插板法基础知识 斯特林数见百科 #include<iostream> #include<cmath> #include<cstdio> #include<cs ...

  4. hdu 4010 动态树 @

    kuangbin模板题,看起来十分高大上 /* *********************************************** Author :kuangbin Created Tim ...

  5. Java中synchronized详解

    synchronized 原则: 尽量避免无谓的同步控制,同步需要系统开销,可能造成死锁 尽量减少锁的粒度 同步方法 public synchronized void printVal(int v) ...

  6. Android使用JNI实现Java与C之间传递数据(转)

    介绍Java如何将数据传递给C和C回调Java的方法.  java传递数据给C,在C代码中进行处理数据,处理完数据后返回给java.C的回调是Java传递数据给C,C需要用到Java中的某个方法,就需 ...

  7. C语言字符串长度(转)

    C语言字符串长度的计算是编程时常用到的,也是求职时必考的一项. C语言本身不限制字符串的长度,因而程序必须扫描完整个字符串后才能确定字符串的长度. 在程序里,一般会用strlen()函数或sizeof ...

  8. PHP模拟POST请求,获取response内容

    /* * 模拟POST请求,获取response内容 */ protected function curl($url, $type, $header, $data) { $CURL_OPTS = ar ...

  9. SGU 275 To xor or not to xor 高斯消元求N个数中选择任意数XORmax

    275. To xor or not to xor   The sequence of non-negative integers A1, A2, ..., AN is given. You are ...

  10. BZOJ 3289: Mato的文件管理 莫队+BIT

    3289: Mato的文件管理 Description Mato同学从各路神犇以各种方式(你们懂的)收集了许多资料,这些资料一共有n份,每份有一个大小和一个编号.为了防止他人偷拷,这些资料都是加密过的 ...