avatar

Catalog
git冲突解决方法

touch ~/.ssh/config 配置config文件

下面对上述配置文件中使用到的配置字段信息进行简单解释:

Host
它涵盖了下面一个段的配置,我们可以通过他来替代将要连接的服务器地址。
这里可以使用任意字段或通配符。
当ssh的时候如果服务器地址能匹配上这里Host指定的值,则Host下面指定的HostName将被作为最终的服务器地址使用,并且将使用该Host字段下面配置的所有自定义配置来覆盖默认的/etc/ssh/ssh_config配置信息。

Port
自定义的端口。默认为22,可不配置

User
自定义的用户名,默认为git,可不配置

HostName
真正连接的服务器地址

PreferredAuthentications
指定优先使用哪种方式验证,支持密码和秘钥验证方式

IdentityFile
指定本次连接使用的密钥文件

实例:

html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Default gitHub user Self
Host github.com
HostName github.com
User git #默认就是git,可以不写
IdentityFile ~/.ssh/id_rsa.github

#Add gitLab user
Host git@gitlab.com
HostName gitlab.com
User git
IdentityFile ~/.ssh/id_rsa.gitlab

# gitee
Host gitee.com
Port 22
HostName gitee.com
User git
IdentityFile ~/.ssh/id_rsa.gitee


# 其他自己搭建的
Host git@git.startdt.net
Port 22
HostName http://git.startdt.net
User git
IdentityFile ~/.ssh/lab_rsa.startdt
Author: Mr.Xu
Link: https://aandborc.gitee.io/blog/2020/03/04/%E5%90%8C%E5%8F%B0%E7%94%B5%E8%84%91%E4%BD%BF%E7%94%A8%E4%B8%A4%E4%B8%AAGit%E5%86%B2%E7%AA%81%E8%A7%A3%E5%86%B3%E6%96%B9%E6%B3%95/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.
Donate
  • 微信
    微信
  • 支付寶
    支付寶

Comment