SSH管理工具

一个用于管理SSH连接的CLI工具,提供交互式TUI界面、会话监控和MCP集成功能。

  • by Jacobo0312
  • Go
  • 本地部署
  • 9 星标
  • 更新于
在 GitHub 查看 Jacobo0312/shellport

使用说明

Teleport to any shell.
Your servers, one keystroke away.


用于管理SSH连接的CLI工具,具有交互式TUI、会话监控和用于Claude Desktop的MCP集成。

先决条件

  • 转到1.25+
  • jq公司 --JSON处理器(brew install jq)
  • Bash/Zsh

安装

make build     # compile binaries
make install   # install to ~/.local/share/shellport + symlink to ~/.local/bin

添加 ~/.zshrc 如果需要:

export PATH="$HOME/.local/bin:$PATH"

用法

shellport                  Interactive host selector (TUI)
shellport add              Add a new SSH host
shellport ls               List all saved hosts
shellport show <id>        Show host details
shellport edit <id>        Edit a host
shellport rm   <id>        Remove a host
shellport mcp              Start MCP server (for Claude Desktop)
shellport --version        Show version
shellport --help           Show help

添加主机

$ shellport add
  Name           My Server
  ID / slug      [my-server]
  Host / IP      10.0.1.50
  SSH user       [ec2-user] deploy
  Port           [22]
  Identity file  ~/.ssh/prod_key
  Tags (comma)   prod, web
  Note           Main web server

  ✓ Host 'My Server' saved.

交互式选择器

跑 shellport 没有理由打开TUI:

  shellport  3
  ──────────────────────────────────
  /
  ──────────────────────────────────
▶ Production Web    deploy@10.0.1.1     [prod, web]
  Staging DB        admin@10.0.2.1      [staging]
  Dev Box           dev@192.168.1.100
  ──────────────────────────────────
  ↑↓ nav  |  enter connect  |  a add  |  e edit  |  d delete  |  q quit

密钥绑定:

关键 行动
↑ / k 向上移动
↓ / j 向下移动
g / Home 转到顶部
G / End 转到底部
Enter 通过SSH连接
a 添加主机
e 编辑所选主机
d 删除所选主机
/ (类型) 筛选主机
Esc 清除过滤器/退出
q 退出

SSH会话监控

当通过TUI连接时, ssh-watch 包装SSH会话和记录:

  • 终端输出(最后300行)
  • 命令历史记录(最近100个命令)
  • 当前目录
  • 连接元数据

会话数据被写入 ~/.shellport/session.json 每500毫秒。

MCP集成(克劳德桌面)

MCP服务器将您的SSH主机和活动会话暴露给Claude Desktop。

设置

添加到您的Claude Desktop MCP配置中(或使用 .mcp.json 在此回购中):

{
  "mcpServers": {
    "shellport": {
      "command": "/path/to/bin/shellport-mcp-server",
      "args": []
    }
  }
}

或手动启动:

shellport mcp

可用的MCP工具

工具 说明
terminal_get_session 活动会话信息(主机、用户、正常运行时间等)
terminal_get_output 终端输出的最后N行
terminal_get_history 带有时间戳的命令历史记录
hosts_list 列出所有已保存的主机(可选标签过滤器)
hosts_get 按ID获取主机的完整详细信息

数据文件

路径 描述
~/.shellport/hosts.json 已保存主机库存
~/.shellport/session.json 活动会话状态

项目结构

shellport/
├── cmd/
│   ├── select/          TUI host selector
│   ├── ssh-watch/       SSH session monitor
│   └── mcp-server/      MCP protocol server
├── internal/
│   ├── model/           Shared types + validation
│   ├── store/           Disk I/O (hosts, sessions)
│   ├── ssh/             SSH args, binary discovery
│   ├── tui/             Interactive UI (bubbletea)
│   ├── mcp/             MCP protocol (JSON-RPC)
│   ├── session/         PTY monitoring + output parsing
│   └── safefile/        Symlink-safe file operations
├── lib/core/            Shell utilities (store, ui, base)
├── bin/                 Shell subcommands (add, ls, show, edit, rm)
├── sshm                 Main CLI dispatcher (bash)
├── Makefile
└── go.mod

发展

make build                        # build binaries
go test ./... -count=1            # run all tests
go test ./... -cover              # run tests with coverage
go vet ./...                      # static analysis
make clean                        # remove built binaries

许可证

麻省理工学院