标签:help config文件 情况 问题 密码 nbsp 提示 hostname continue
[credential]
helper = store
[credential]
helper = store
ssh-keygen -t rsa -C "lixionghui@tydic.com" -f ~/.ssh/id_rsa_shs
ssh-keygen -t rsa -C "lixionghui@tydic.com" -f ~/.ssh/id_rsa_gd
查看生成的秘钥
cat ~/.ssh/id_rsa_sh.pub
cat ~/.ssh/id_rsa_gd.pub
ssh-keygen -t rsa -C "lixionghui@tydic.com" -f ~/.ssh/id_rsa_shs
ssh-keygen -t rsa -C "lixionghui@tydic.com" -f ~/.ssh/id_rsa_gd
查看生成的秘钥
cat ~/.ssh/id_rsa_sh.pub
cat ~/.ssh/id_rsa_gd.pub
vi ~/.ssh/config
- guangdong Git
Host gdgit
HostName 172.26.6.67
User lixionghui@tydic.com
IdentityFile ~/.ssh/id_rsa_gd
- shanghai Git
Host shgit
HostName 116.228.151.221
User lixionghui@tydic.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_sh
Port 20022
Host就是每个SSH连接的单独代号,IdentityFile告诉SSH连接去读取哪个私钥。
检查配置
cat ~/.ssh/config
如有问题,可以用下面命令替换内容
cat >~/.ssh/config
- guangdong Git
Host gdgit
HostName 172.26.6.67
User lixionghui@tydic.com
IdentityFile ~/.ssh/id_rsa_gd
- shanghai Git
Host shgit
HostName 116.228.151.221
User tianshuo@tydic.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_sh
Port 20022
vi ~/.ssh/config
- guangdong Git
Host gdgit
HostName 172.26.6.67
User lixionghui@tydic.com
IdentityFile ~/.ssh/id_rsa_gd
- shanghai Git
Host shgit
HostName 116.228.151.221
User lixionghui@tydic.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_sh
Port 20022
Host就是每个SSH连接的单独代号,IdentityFile告诉SSH连接去读取哪个私钥。
检查配置
cat ~/.ssh/config
如有问题,可以用下面命令替换内容
cat >~/.ssh/config
- guangdong Git
Host gdgit
HostName 172.26.6.67
User lixionghui@tydic.com
IdentityFile ~/.ssh/id_rsa_gd
- shanghai Git
Host shgit
HostName 116.228.151.221
User tianshuo@tydic.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_sh
Port 20022
ssh-agent bash
ssh-add ~/.ssh/id_rsa_sh
ssh-add ~/.ssh/id_rsa_gd
参考如下:
$ ssh-agent bash
bash-3.1$ ssh-add ~/.ssh/id_rsa_sh
Identity added: /c/Users/xjch/.ssh/id_rsa_sh (/c/Users/xjch/.ssh/id_rsa_sh)
bash-3.1$ exit
exit
ssh-agent bash
ssh-add ~/.ssh/id_rsa_sh
ssh-add ~/.ssh/id_rsa_gd
参考如下:
$ ssh-agent bash
bash-3.1$ ssh-add ~/.ssh/id_rsa_sh
Identity added: /c/Users/xjch/.ssh/id_rsa_sh (/c/Users/xjch/.ssh/id_rsa_sh)
bash-3.1$ exit
exit
查看生成的秘钥
cat ~/.ssh/id_rsa_sh.pub
cat ~/.ssh/id_rsa_gd.pub
查看生成的秘钥
cat ~/.ssh/id_rsa_sh.pub
cat ~/.ssh/id_rsa_gd.pub
ssh -T git@gdgit
Welcome to GitLab, ###!
ssh -T git@shgit
Welcome to GitLab, ###!
如果是第一次,可能需要提示你输入yes才可以
ssh -T git@shgit
The authenticity of host ‘[116.228.151.221]:20022 ([116.228.151.221]:20022)‘ can‘t be established.
RSA key fingerprint is 78:73:cb:9e:2a:83:4d:29:e3:de:62:c7:68:1c:46:2c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘[116.228.151.221]:20022‘ (RSA) to the list of known hosts.
Welcome to GitLab, ###!
ssh -T git@gdgit
Welcome to GitLab, ###!
ssh -T git@shgit
Welcome to GitLab, ###!
如果是第一次,可能需要提示你输入yes才可以
ssh -T git@shgit
The authenticity of host ‘[116.228.151.221]:20022 ([116.228.151.221]:20022)‘ can‘t be established.
RSA key fingerprint is 78:73:cb:9e:2a:83:4d:29:e3:de:62:c7:68:1c:46:2c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘[116.228.151.221]:20022‘ (RSA) to the list of known hosts.
Welcome to GitLab, ###!
广东git
$ git clone git@gdgit:****/****.git
如果从git网站上获取的值为:git@172.26.6.67:****/****.git,需要将ip 172.26.6.67 替换为host:gdgit 如: git@gdgit:****/****.git
上海git
$ git clone git@shgit:merchant/merchant_core.git
$ git clone git@shgit:merchant/merchant_portal.git
如果从git网站上获取的值为如:git@localhost:merchant/merchant_core.git,需要将localhost替换为host:shgit 如: git@shgit:merchant/merchant_core.git
参考文档:
http://www.2cto.com/os/201402/281792.html
http://my.oschina.net/csensix/blog/184434
~/.ssh/config的额外配置
TCPKeepAlive yes
IdentitiesOnly yes
TCPKeepAlive yes
当达成联机后,服务器会一直传送 TCP 封包给客户端藉以判断对方式否一直存在联机。
不过,如果联机时中间的路由器暂时停止服务几秒钟,也会让联机中断喔!
在这个情况下,任何一端死掉后,SSH可以立刻知道!而不会有僵尸程序的发生!
但如果你的网络或路由器常常不稳定,那么可以设定为 no 的啦!
IdentitiesOnly 只接受SSH key 登录
广东git
$ git clone git@gdgit:****/****.git
如果从git网站上获取的值为:git@172.26.6.67:****/****.git,需要将ip 172.26.6.67 替换为host:gdgit 如: git@gdgit:****/****.git
上海git
$ git clone git@shgit:merchant/merchant_core.git
$ git clone git@shgit:merchant/merchant_portal.git
如果从git网站上获取的值为如:git@localhost:merchant/merchant_core.git,需要将localhost替换为host:shgit 如: git@shgit:merchant/merchant_core.git
参考文档:
http://www.2cto.com/os/201402/281792.html
http://my.oschina.net/csensix/blog/184434
~/.ssh/config的额外配置
TCPKeepAlive yes
IdentitiesOnly yes
TCPKeepAlive yes
当达成联机后,服务器会一直传送 TCP 封包给客户端藉以判断对方式否一直存在联机。
不过,如果联机时中间的路由器暂时停止服务几秒钟,也会让联机中断喔!
在这个情况下,任何一端死掉后,SSH可以立刻知道!而不会有僵尸程序的发生!
但如果你的网络或路由器常常不稳定,那么可以设定为 no 的啦!
IdentitiesOnly 只接受SSH key 登录
标签:help config文件 情况 问题 密码 nbsp 提示 hostname continue
原文地址:https://www.cnblogs.com/apescode/p/9155024.html