{"id":13826085,"url":"https://github.com/izuolan/pshell","last_synced_at":"2025-07-08T23:31:00.411Z","repository":{"id":92539477,"uuid":"75942583","full_name":"izuolan/Pshell","owner":"izuolan","description":"ICMP/IP tunnel manager for Linux.","archived":false,"fork":false,"pushed_at":"2017-11-19T08:37:25.000Z","size":78,"stargazers_count":25,"open_issues_count":0,"forks_count":13,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T22:12:02.130Z","etag":null,"topics":["docker","hans","icmp","ptunnel","shell","socks","tunnel"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/izuolan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-12-08T13:59:56.000Z","updated_at":"2024-12-03T03:13:53.000Z","dependencies_parsed_at":"2023-03-02T18:45:24.711Z","dependency_job_id":null,"html_url":"https://github.com/izuolan/Pshell","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/izuolan/Pshell","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izuolan%2FPshell","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izuolan%2FPshell/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izuolan%2FPshell/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izuolan%2FPshell/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/izuolan","download_url":"https://codeload.github.com/izuolan/Pshell/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/izuolan%2FPshell/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264365433,"owners_count":23596828,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["docker","hans","icmp","ptunnel","shell","socks","tunnel"],"created_at":"2024-08-04T09:01:31.900Z","updated_at":"2025-07-08T23:31:00.091Z","avatar_url":"https://github.com/izuolan.png","language":"C","funding_links":[],"categories":["\u003ca id=\"01e6651181d405ecdcd92a452989e7e0\"\u003e\u003c/a\u003e工具"],"sub_categories":["\u003ca id=\"9d6789f22a280f5bb6491d1353b02384\"\u003e\u003c/a\u003e隧道\u0026\u0026穿透"],"readme":"这是一个 ICMP/IP 隧道管理脚本，从服务器到本地的全部操作，都可以通过这个脚本完成，目前完美支持主流 Linux 发行版（能运行最新版本 Docker 即可）。\n\n#### 可以用来做什么\n\n* 内网穿透（从外网访问内网的主机，比如在家里访问学校内网的资源）\n* 绕过认证（绕过一般的网络认证，比如绕过学校网络认证直接上网）\n* 网络代理（又双叒叕一个翻墙姿势，比如服务端放在海外就可以翻墙了）\n\n#### 功能\n\n* 支持服务器自动部署并启动，服务端遇到意外可以自动重启。\n* 支持本地自动部署并启动，支持 ICMP/IP 双协议隧道。\n* 支持断线自动重连。\n* 提供直观的监视器，可以实时查看连接状态。\n* 支持指定网卡分享 socks5 代理给他人。\n* 支持 socks5 转发为 http 代理。\n* 支持 TCP-BBR 算法，极大提高网速（需要内核支持）。\n* 密码认证。\n* 自动更新脚本。\n\n#### 待添加/修复功能\n\n* 支持自动修复 http 代理并允许指定 http 端口。\n* 自动启用负载均衡。\n* TCP-BBR 算法自动启用。\n* 添加 DNS Tunnel 功能。\n* **proxy.list 文件最后一行不是空行会执行失败**。\n\n```shell\n$ ./Pshell.sh -h\n------------------------------------------------------------------------------\n   ___ ____ __  __ ____   _____ ____    ____  _          _ _ \n  |_ _/ ___|  \\/  |  _ \\ / /_ _|  _ \\  / ___|| |__   ___| | |\n   | | |   | |\\/| | |_) / / | || |_) | \\___ \\| '_ \\ / _ \\ | |\n   | | |___| |  | |  __/ /  | ||  __/   ___) | | | |  __/ | |\n  |___\\____|_|  |_|_| /_/  |___|_|     |____/|_| |_|\\___|_|_|\n  Email: i@zuolan.me                 Blog: https://zuolan.me\n  一个隧道部署与代理管理的脚本。不加参数直接运行脚本即可连接。\n------------------------------------------------------------------------------\n  可选参数         -  说明\n------------------------------------------------------------------------------\n  -d (driver)    -  指定网卡（enp3s0|wlp2s0|eth0|wlan0），默认全部。\n  -e (edit)      -  编辑配置列表。\n  -f (fast)      -  快速模式（切换为 IP 协议隧道，速度更快，安全性降低）。\n  -h (help)      -  显示帮助信息。更详细说明请阅读 README 文件。\n  -k (kill)      -  杀死 autossh 和 sshd 进程（当连接长时间中断时使用）。\n  -l (local)     -  安装本地守护容器。\n  -m (monitor)   -  查看代理与容器运行的情况。\n  -n (net)       -  统计代理端口的流量（-n set/unset 开启/重置流量统计）。\n  -p (port)      -  选择本地 HTTP 代理端口（默认配置/etc/privoxy/config）。\n  -s (server)    -  安装服务器守护进程。\n  -u (update)    -  检测版本以及更新脚本。\n------------------------------------------------------------------------------\n```\n\n# 安装\n\n## 第零步、ssh 免密码设置\n\n在本地生成一对密钥（邮箱替换为你的邮箱）：\n\n```shell\nssh-keygen -t rsa -b 4096 -C \"i@zuolan.me\"\n```\n\n把公钥（id_rsa.pub）内容复制粘贴到服务器的 `~/.ssh/authorized_keys` 文件中：\n\n```shell\ncat ~/.ssh/id_rsa.pub \u003e\u003e ~/.ssh/authorized_keys\n```\n\n## 第一步、服务器安装\n\n执行 `sudo ./Pshell.sh --server` 即可自动安装并启动。服务器就一句话。\n\n## 第二步、填写本地配置文件\n\n现在回到本地，在运行脚本连接之前需要填写配置文件，模板如下。打开 `proxy.list`，然后按照下面的模板填写你的配置。\n\n```shell\n节点名称:容器名称:容器端口:Socks5端口:服务器IP:密码:密钥\n```\n\n例如：\n\n```shell\n广州:gz:8001:10001:123.45.67.89:pass1:~/.ssh/id_rsa.gz\n香港:hk:8002:10002:123.45.67.89:pass1:~/.ssh/id_rsa.hk\n青岛:qd:8003:10003:123.45.67.89:pass2:~/.ssh/id_rsa.qd\n东京:to:8004:10004:123.45.67.89:password:~/.ssh/id_rsa.to\n```\n\n填完就可以进行下一步了，但如果你想更详细定义脚本变量可以在脚本头部中设置（不建议）。\n\n## 第三步、本地电脑安装\n\n执行 `./Pshell.sh --local` 即可自动安装并运行。\n\n# 使用\n\n下面方法任选其一。\n\n## 一、基于 SSH 的 Socks5 代理\n\n### 1. ICMP 模式（限速150KB/s）\n\n使用 `./Pshell.sh` 直接运行脚本即为 ICMP 协议隧道，然后你可以使用配置文件中设置的 Socks5 端口（见安装步骤第二步）连接到外网。设置方法和普通 Socks5 端口使用一样。（例如 Google Chrome 中的插件 SwitchyOmega。）\n\n### 2. IP 模式（不限速）\n\n使用 `./Pshell.sh -f` 即可启用 IP 协议的隧道，相比使用 ICMP 协议的隧道而言，IP 协议的隧道速度更快（有可能被云服务提供商误判为DDos攻击）。启用之后使用方式和 ICMP 模式一样，连接 Socks5 端口即可。\n\n## 二、基于 IP 协议的端口映射\n\n由于 SSH 的连接不是非常稳定，即便加了自动重连的方法还是会出现短暂的断网现象（自动重连大概要零点几秒），对于下载、游戏等过程有比较大影响，所以建议设置端口映射，由于 ICMP 协议速度不快，我就不写 ICMP 的端口映射了，用 ICMP 刷个网页基本不会感受到断网的情况。\n\n\u003e 由于脚本尚未完善，目前仅支持一台服务器的端口映射，如果你列表中有多台服务器，只会连接列表中的第一台服务器。\n\n以`广州:gz:8001:10001:123.45.67.89:pass1:~/.ssh/id_rsa.gz`为例，完成服务端和客户端的安装之后，在服务端启动一个代理（SS、SSR之类的你懂的软件），然后本地可以通过`10.1.2.1`这个地址连接到服务器的代理软件。\n\n服务端完整示例：\n\n```shell\n# 安装 Pshell 服务端\n$ ./Pshell.sh -s\n# 安装 Shadowsocks 服务端\n$ docker run -d --name ss -p 10001:10001 mritd/shadowsocks -s \"-s 0.0.0.0 -p 10001 -k ss_password -m aes-256-cfb\"\n```\n\n然后回到本地的电脑，安装好 Pshell 本地端之后（`./Pshell.sh -l`），打开 Shadowsocks 客户端，服务器地址为`10.1.2.1`，其他根据你的设置改变。\n\n现在你可以使用 IP 协议稳定连接网络了。\n\n# 扩展\n\n## 一、Socks5 转 http\n\n有些软件不支持 Socks5 代理协议，所以提供端口转换功。\n\n使用 `./Pshell.sh -p \u003cport\u003e` 可以指定其中一个 socks5 端口转换为 http 端口（转换后 http 协议代理端口为 8118）。\n\n\u003e 端口转换功能是保存起来的，不需要每次运行都指定它，除非你想重新指定转换的 socks5 端口。\n\n## 二、分享 Socks5 端口\n\n如果你想分享代理给他人用，可以使用 `./Pshell.sh -d \u003cenp3s0\u003e` 参数指定网卡分享 Socks5 端口。\n\n\u003e 常用的网卡有 enp3s0|wlp2s0|eth0|wlan0 这些，使用 `ifconfig` 命令可以查看。\n\n注意一点就是 Privoxy 的 8118 端口默认为仅 localhost 访问，如果需要他人访问，你还需要修改 localhost 为其他地址（例如 0.0.0.0），这样他人可以通过这个 http 端口访问外网。\n\n## 三、重启 sshd 进程\n\n在使用过程中可能会出现 sshd 进程崩溃的情况，这时候明明没有连接异常但死活连不上。\n\n这个时候你可以使用 `./Pshell.sh -k` 参数来杀死崩溃 sshd 进程并手动执行 `./Pshell.sh` 重新启动 sshd 进程。\n\n# 最后\n\n使用 `alias` 指定脚本为特定命令即可更加方便启动。\n\n其他功能自己发现（其实也没什么其他功能了），在脚本中可以看到全部可选参数。","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizuolan%2Fpshell","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fizuolan%2Fpshell","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fizuolan%2Fpshell/lists"}