git command tips: ssh/public key/github git server test

本文详细介绍了如何使用sshgen生成SSH密钥对,并将其保存于~/.ssh目录下,包括私钥(id_rsa)与公钥(id_rsa.pub)。阐述了如何上传公钥至GitHub服务器,以及通过设置权限确保密钥安全。最后,通过实例展示了如何利用SSH密钥进行GitHub认证,实现免密码克隆仓库。

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

1. ssh gen  saved in ~/.ssh 

~/.ssh/  

-rw------- 1 lake lake 1743 Mar  2 10:02 id_rsa  ==========> Private key
-rw-r--r-- 1 lake lake  401 Mar  2 10:02 id_rsa.pub  ============> Public key 
-rw-r--r-- 1 lake lake 9946 Mar  2 10:26 known_hosts  =================> Know hosts public key files from the 3rd party
2. upload ssh public key into git server

~/.ssh/id_rsa.pub   ======>  github.com/yourname  =====> Setting ===> SSH public key upload 

 

3. Test 

 

 

 

lake@lake-Latitude-5491:~$ chmod   600  .ssh/id_rsa
lake@lake-Latitude-5491:~$ ssh  -vT  git@github.com
OpenSSH_7.6p1 Ubuntu-4ubuntu0.1, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [52.74.223.119] port 22.
debug1: Connection established.
debug1: identity file /home/lake/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/lake/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lake/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lake/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lake/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lake/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/lake/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
...........................

...........

...........

debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
Hi lakehu! You've successfully authenticated, but GitHub does not provide shell access.
debug1: channel 0: free: client-session, nchannels 1
Transferred: sent 3144, received 2228 bytes, in 7.7 seconds
Bytes per second: sent 410.3, received 290.7
debug1: Exit status 1
lake@lake-Latitude-5491:~$ ssh  -T  git@github.com
Enter passphrase for key '/home/lake/.ssh/id_rsa': 
Hi lakehu! You've successfully authenticated, but GitHub does not provide shell access.
lake@lake-Latitude-5491:~$ git clone  git@github.com:lakehu/example-code.git
Cloning into 'example-code'...
Enter passphrase for key '/home/lake/.ssh/id_rsa': 
remote: Enumerating objects: 2437, done.
remote: Total 2437 (delta 0), reused 0 (delta 0), pack-reused 2437
Receiving objects: 100% (2437/2437), 4.87 MiB | 18.00 KiB/s, done.
Resolving deltas: 100% (765/765), done.
 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值