Skip to content

Instantly share code, notes, and snippets.

@bio-punk
Last active December 27, 2025 17:42
Show Gist options
  • Select an option

  • Save bio-punk/6883a55423d40f53803b75aef988e0a8 to your computer and use it in GitHub Desktop.

Select an option

Save bio-punk/6883a55423d40f53803b75aef988e0a8 to your computer and use it in GitHub Desktop.
ssh over http proxy #run #linux

通过 http/https 代理转发 ssh 请求

问题

  1. 资源无法联网
  2. 拥有http/https代理,形如export http://${proxy_username}:${proxy_password}@${proxy_addr}:${proxy_port}
  3. 需要访问外部的ssh资源,如git@github.com

需求

安装 corkscrew 需要root权限

步骤

安装corkscrew

sudo apt install -y corkscrew

配置ssh代理

代理文件 ~/.ssh/config

Host github.com
        ProxyCommand corkscrew {proxy_addr} {proxy_port} %h %p /root/.ssh/corkscrew_auth
        IdentityFile ~/.ssh/id_ed25519_test

注意

  1. 如果http代理需要用户名和密码,则添加~/.ssh/corkscrew_auth配置
{proxy_username}:{proxy_password}
  1. github/gitlab不支持rsa密钥,建议使用ed25519
ssh-keygen -t ed25519 -C "only test"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment