OrbStack SSH 命令速查手册(简洁版)

社区话题 Linux/macOS 与自动化运维 OrbStack SSH 命令速查手册(简洁版)

  • 该话题为空。
正在查看 0 条回复
  • 作者
    帖子
    • #1166

      追光
      管理员

      # OrbStack SSH 命令速查手册(简洁版)

      ? 基础连接命令

      bash

      # 登录默认机器(使用当前 macOS 用户名)
      ssh orb
      
      # 登录指定机器(如 'ubuntu')
      ssh ubuntu@orb
      
      # 以指定用户登录(如 'root')
      ssh root@orb
      
      # 以指定用户登录指定机器(如 root@ubuntu)
      ssh root@ubuntu@orb

      > ? 提示:用 `orb default ` 可设置默认机器。

      ?️ 连接配置信息(用于非 OpenSSH 工具)

      bash
      Host:     localhost
      Port:     32222
      User:     <user>@<machine>  # 如: ubuntu@ubuntu 或 root
      Key:      ~/.orbstack/ssh/id_ed25519

      > ⚠️ 注意:密码登录已禁用,仅支持密钥认证。

      ? 密钥管理

      bash

      # 查看/替换 OrbStack 专用密钥
      ls ~/.orbstack/ssh/
      
      # 如需使用自己的密钥,可创建软链接(操作后需重启 OrbStack)
      ln -sf ~/.ssh/id_ed25519 ~/.orbstack/ssh/id_ed25519
      ln -sf ~/.ssh/id_ed25519.pub ~/.orbstack/ssh/id_ed25519.pub
      
      # 添加其他公钥授权(编辑后需重启 OrbStack)
      nano ~/.orbstack/ssh/authorized_keys

      > ✅ 支持 ECDSA / RSA / Ed25519 密钥类型。

      ? 与工具集成

      #VS Code / Fleet
      – 安装 **Remote – SSH** 插件
      – 直接连接主机名:`orb`

      #JetBrains IDE
      – 使用上述「连接配置信息」填写主机、端口、用户、私钥路径

      #Ansible(示例 inventory)

      ini

      [servers]
      ubuntu@orb  ansible_user=ubuntu
      root@ubuntu@orb ansible_user=root@ubuntu

      ? 远程访问限制

      bash

      # OrbStack SSH 服务默认仅允许 localhost 连接
      # 如需从其他设备访问,请使用 SSH 端口转发:
      ssh -L 32222:localhost:32222 your-mac-user@your-mac-ip
      # 然后在远程设备上连接:
      ssh -p 32222 user@machine@localhost

      ? 端口转发(通常不需要)

      bash

      # 本地端口转发(-L)
      ssh -L 8080:localhost:80 orb
      
      # 远程端口转发(-R)
      ssh -R 9090:localhost:3000 orb

      > ? OrbStack 已自动将 Linux 服务映射到 macOS `localhost`,通常无需手动转发。

      ✅ 代理与密钥转发

      bash

      # 无需配置!SSH Agent 已自动转发到 Linux 机器
      # 可直接在 Linux 中使用 macOS 的 SSH 密钥进行 git push / ssh 连接等操作

      ? **总结**:OrbStack SSH 主要用于工具集成(如 VSCode、Ansible),日常交互推荐直接使用 `orb` 命令获得更无缝体验。

正在查看 0 条回复
  • 在下方一键注册,登录后就可以回复啦。