ssh 秘钥别名登录
在/etc/ssh/ssh_config
或 ~/.ssh/config
中输出以下行 (若文件不存在,新建即可)
1
2
3
Host dev
HostName www.ex.com
User root
然后使用ssh dev
即可登录至远程服务器
git多账户
同上,在/etc/ssh/ssh_config
或 ~/.ssh/config
中配置git多账户登录
1
2
3
4
5
6
7
8
9
10
11
12
13
# 配置github.com
Host github.com
HostName github.com
IdentityFile C:\\Users\\god\\.ssh\\id_rsa_github
PreferredAuthentications publickey
User tillend
# 配置git.oschina.net
Host git.oschina.net
HostName git.oschina.net
IdentityFile C:\\Users\\god\\.ssh\\id_rsa_oschina
PreferredAuthentications publickey
User tillend
显示对应账户
1
2
$ ssh -T git@github.com
Hi tillend! You've successfully authenticated, but GitHub does not provide shell access.
在使用时需要注意,不能设置全局的
username
和
1
2
3
# 取消全局 username, email
git config --global --unset user.name
git config --global --unset user.email
git代理
http代理
命令形式
1
2
git config --global http.https://github.com.proxy socks5://127.0.0.1:1080
git config --global https.https://github.com.proxy socks5://127.0.0.1:1080
配置形式
1
2
3
4
5
Host github.com
HostName github.com
User root
ProxyCommand connect -H 127.0.0.1:1080 %h %p
# ProxyCommand connect -S 127.0.0.1:1080 %h %p (socks5)
ssh代理
配置形式
1
2
3
4
Host github.com
HostName github.com
User root
ProxyCommand nc -v -x 127.0.0.1:1080 %h %p
参考资料:
1.ssh 秘钥别名登录
2.Windows Git多账号配置