# 超新星小白勇闯github -ssh

超新星小白

超新星小白勇闯github -ssh

作为一枚超新星编程小白,在使用github时发生了许多小插曲。
今天分享一下如何设置ssh key
设置好了之后就可以将github上的代码包直接使用"ssh git xxx"命令远程下载在本地了哦!!
centos8 生产环境

生成本地SSH key

[root@s_182 ~]# cd ~/.ssh
[root@s_182 .ssh]# ls
authorized_keys  id_rsa  id_rsa.pub  known_hosts
[root@s_182 .ssh]# cat id_rsa.pub
ssh-rsa AAAAB3....(省略)....c= root@s_182

将id_rsa.pub上所有的内容复制粘贴到github上
执行

[root@s_182 ~]# ssh -vT git@github.com

插曲来了!!!出现问题了

[root@s_182 ~]# ssh -vT git@github.com
OpenSSH_8.0p1, OpenSSL 1.1.1k  FIPS 25 Mar 2021
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: configuration requests final Match pass
debug1: re-parsing configuration
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Reading configuration data /etc/ssh/ssh_config.d/05-redhat.conf
debug1: Reading configuration data /etc/crypto-policies/back-ends/openssh.config
debug1: Connecting to github.com [20.205.243.166] port 22.
debug1: connect to address 20.205.243.166 port 22: Connection timed out
ssh: connect to host github.com port 22: Connection timed out

别慌,写一个config,主要是指定一下端口

[root@s_182 ~]# cd ~/.ssh
[root@s_182 .ssh]# vim config

[root@s_182 .ssh]# cat config

Host github.com
User “邮箱xx@xx.com”
Hostname ssh.github.com
Port 443

继续执行

[root@s_182 ~]# ssh -vT git@github.com

....省略....
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3084, received 3112 bytes, in 0.7 seconds
Bytes per second: sent 4319.9, received 4359.1
debug1: Exit status 1

[root@s_182 ~]# ssh -T git@github.com
Hi xxxx! You've successfully authenticated, but GitHub does not provide shell access.