ssh入门

take away knowledge & concept

对于private repo, 即便是clone,也需要ssh

ssh-keygen命令生成的两份文件:私钥和公钥(.pub)。你要把public key交给github

每一次 clone / push的Authentification过程:
github服务器给你的机器发公钥。 你的机器上~/.ssh/路径下存了唯一的私钥与之对应。即完成身份验证。

glossary

SSH: secure shell protocal

github场景-S1:增添新密码

  • 当你的项目团队有多个成员,你作为项目的owner,需要为你的团队成员设置SSH,这样他们才能在他们的电脑上更新项目(clone, push)
  • 还有一个情况,你有多台工作本,你需要为每一台机器上添加SSH,并在个人g-hub账户添加public key

background and task:

linux + Windows 共同运营hexo blog. Add _post to repo, clone on git

过程记录()

  1. 最开始用https协议下载private repo代码失败。遂该用ssh。git clone git@github.com:Optimushimeself/blogsource.git自然报错。因为还没在我的github账号中配置本机的SSH。
  2. ssh-keygen tyrone@Matrix:~/.ssh$ ssh-keygen -t [加密算法] -f [sshfileName] t: type. github使用ed25519。 passphrase口令为空。自然也没关ssh-agent之类的“高级功能”。
  3. ssh-keygen得到两个文件,.pub后缀是公钥,扔到github->setting->SSH&GPG Keys
  4. (不知道是否靠谱)遇到一些代理问题,调成了全局代理,创建~/.ssh/config。重新运行git clone git@github.com:OptimusHimself/blogsource.git,中途谈了一个是否信任(老熟人了),无脑yes,最后成功克隆项目。

问题/故障记录

1
2
3
4
5
6
7
8
\\ 网络问题?
Cloning into 'blogsource'...
kex_exchange_identification: read: Connection reset by peer
Connection reset by 20.205.243.166 port 22
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

github场景-S2:原来的私钥丢失or忘记passphrase()

这就是我为什么建议小白们最开始学习没必要设置passphrase,因为你会忘掉。 不过,只要能记得自己github账号的密码,问题都不大~
打开github网站,github->setting->SSH&GPG Keys删掉你之前创建的钥匙,重新走一遍 github场景-S1

使用ssh登陆服务器:传文件,训练模型….


ssh入门
https://optimushimself.github.io/2025/04/29/ssh入门/
作者
Tyrone Opting
发布于
2025年4月29日
许可协议