Config Github/Gitlab Problem&solution

本文介绍了如何解决GitHub和GitLab上通过SSH连接时出现的权限拒绝和连接超时的问题。对于权限拒绝问题,文章提供了加载SSH密钥的方法;针对连接超时问题,则给出了配置SSH文件的具体步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Config Github/Gitlab Problem&solution

1.(1)problem

cdlab@cdlab-MS-7A95:~$ ssh -T git@ssh.github.com
Warning: Permanently added the RSA host key for IP address '192.30.253.122' to the list of known hosts.
git@ssh.github.com: Permission denied (publickey).

1.(2)solution

cdlab@cdlab-MS-7A95:~$ eval "$(ssh-agent -s)"
cdlab@cdlab-MS-7A95:~$ ssh-add /home/cdlab/.ssh/githubkey
cdlab@cdlab-MS-7A95:~$ ssh-add -l -E md5

2.(1)problem

cdlab@cdlab-MS-7A95:~/.ssh$ ssh -T git@github.com
ssh: connect to host github.com port 22: Connection timed out

cdlab@cdlab-MS-7A95:~/.ssh$ ssh -T git@gitlab.com
ssh: connect to host gitlab.com port 22: Connection timed out

2.(2)solution

#Github solution
create file ~/.ssh/config (On windows probably %USERPROFILE%\.ssh\config)
Paste the following code in config file:
	Host github.com
	User git
	Hostname ssh.github.com
    
#Gitlab solution
Paste the following code in config file:
	Host gitlab.com
	Hostname altssh.gitlab.com
	User git
	Preferredauthentications publickey
	IdentityFile ~/.ssh/gitlabkey
	Port 443
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值