小技巧

如何一次性删除所有以某关键词结尾的文件

其他类型删除以此类推

1
find . -type f -name '*.ko' -exec rm -rf {} \;

Git push报错

1
ssh: connect to host github.com port 22: Connection refused fatal: Could not read from remote repository.  Please make sure you have the correct access rights and the repository exists.

这个错误表明 Git 无法通过 SSH(端口 22)连接到 GitHub。可能的原因和解决方法如下:

1. 检查 SSH 连接

运行以下命令测试 SSH 连接:

1
ssh -T git@github.com

如果连接被拒绝,可能是网络或防火墙问题。

2. 改用 HTTPS 协议

如果 SSH 被屏蔽,可以临时改用 HTTPS:

1
2
git remote set-url origin https://github.com/用户名/仓库名.git
git push

(需要输入 GitHub 账号密码或个人访问令牌)

3. 尝试 SSH 端口 443

如果 22 端口被屏蔽,GitHub 也支持通过 443 端口使用 SSH。编辑 ~/.ssh/config 文件:

1
2
3
4
5
6
Host github.com
User xxxxqq.com
Hostname ssh.github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Port 443

然后再次测试 SSH 连接。

4. 检查防火墙/代理设置

  • 确保本地防火墙或公司网络未屏蔽 SSH(端口 22/443)
  • 如果使用代理,需配置 Git 使用代理:
    1
    2
    git config --global http.proxy http://代理地址:端口
    git config --global https.proxy https://代理地址:端口

5. 验证 SSH 密钥

确保你的 SSH 密钥已添加到 GitHub:

1
cat ~/.ssh/id_rsa.pub

然后将内容粘贴到 GitHub Settings → SSH and GPG keys。

6. 检查仓库是否存在

确认远程仓库地址正确且存在:

1
git remote -v