SSHP 是一个简单而强大的 SSH 配置管理工具,它允许你通过 YAML 配置文件管理多个 SSH 连接,并提供简单的命令行界面来连接到这些主机。
- 通过 YAML 文件管理多个 SSH 连接配置
 - 支持按组织结构管理主机
 - 自动使用保存的凭据连接到主机
 - 支持默认配置和主机特定配置
 - 简单直观的命令行界面
 
- 
确保你已安装
yq工具:# 使用 brew 安装(macOS) brew install yq # 使用 apt 安装(Debian/Ubuntu) apt install yq - 
安装
sshpass工具(用于自动输入密码):# macOS brew install sshpass # Debian/Ubuntu apt-get install sshpass # CentOS/RHEL yum install sshpass - 
下载
sshp.sh脚本并添加执行权限:git clone https://github.com/wacxz/sshp.git cd sshp chmod +x sshp.sh ln -s $(pwd)/sshp.sh /usr/local/bin/sshp sshp - 
可选:将脚本添加到你的 PATH 中,以便在任何位置使用它。
 
SSHP 使用 ~/.sshp/sshp.yaml 作为配置文件。配置文件的结构如下:
group:
  name: "group name" # group name can be empty
  default:
    port: 22
    user: root
    password: your_password
  list:
    ip1:
      port: 端口号
      user: 用户名
      password: 密码
    ip2:
    ip3:
      # 如果未指定,将使用默认配置production:
  name: "生产环境"
  default:
    port: 22
    user: admin
    password: secure_password
  list:
    192.168.1.10:
    192.168.1.11:
      user: root  # 覆盖默认用户
development:
  default:
    port: 2222
    user: dev
    password: dev_password
  list:
    127.0.0.1:sshp -g
sshp -g production
sshp 127.0.0.1
sshp -e
sshp -h
- 密码以明文形式存储在配置文件中,请确保配置文件的权限设置正确
 - 建议将配置文件的权限设置为仅当前用户可读写:
chmod 600 ~/.sshp/sshp.yaml - 对于生产环境,建议使用 SSH 密钥认证而不是密码
 
MIT