将本地密钥上传到这个实现免密登录

User: ssh -p 32703 root@connect.nmb1.seetacloud.com

将本地密钥上传到这个实现免密登录

GitHub Copilot: 按以下步骤做即可:

  1. 生成密钥(如果已存在可跳过)

    在 PowerShell 里执行:

    ssh-keygen -t ed25519 -C "your_email@example.com"

  2. 复制公钥内容

    在 PowerShell 里执行:

    Get-Content $env:USERPROFILE.ssh\id_ed25519.pub

  3. 上传到服务器(免密登录)

    执行:

    ssh -p 32703 root@connect.nmb1.seetacloud.com

    登录后执行:

    mkdir -p ~/.ssh ; chmod 700 ~/.ssh

    echo "粘贴上一步的公钥内容" >> ~/.ssh/authorized_keys

    chmod 600 ~/.ssh/authorized_keys

  4. 测试免密

    退出后再次执行:

    ssh -p 32703 root@connect.nmb1.seetacloud.com

如果你已有不同的公钥文件名(比如 id_rsa.pub),把第2步路径换成对应文件即可。

User: 你来操作

GitHub Copilot: Ran terminal command: Test-Path env:USERPROFILE.ssh\\id_ed25519.pub; Test-Path env:USERPROFILE.ssh\id_rsa.pub

已有 id_rsa.pub 密钥,现在读取公钥内容并上传到服务器:

Ran terminal command: $pubkey = Get-Content KaTeX parse error: Undefined control sequence: \id at position 21: ...SERPROFILE\.ssh\̲i̲d̲_rsa.pub; ssh -...pubkey' >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys && echo 'Done!'"

需要输入密码才能完成上传。请输入服务器密码:

Ran terminal command

看起来命令被中断了。我用另一种方式来完成 - 先使用 ssh-copy-id 或者手动方式。让我用 type 命令通过管道上传:

Ran terminal command: type $env:USERPROFILE.ssh\id_rsa.pub | ssh -p 32703 root@connect.nmb1.seetacloud.com "mkdir -p ~/.ssh && chmod 700 ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"

公钥已成功上传!现在测试免密登录是否生效:

Ran terminal command: ssh -p 32703 root@connect.nmb1.seetacloud.com "echo '免密登录成功!' && hostname"

✅ 免密登录配置成功!

现在你可以直接使用以下命令登录服务器,无需输入密码:

复制代码
ssh -p 32703 root@connect.nmb1.seetacloud.com
相关推荐
m0_646429971 天前
VS Code Remote SSH 使用 Codex:通过 SSH 转发本地代理
运维·ssh
SoStraw1 天前
没有公网IP怎么远程SSH?设备只装 p2pssh-server,File2File 一键连回去
ssh·内网穿透·远程ssh·webrpc·无公网ip·file2file·p2pssh
程序员-Benothing2 天前
SSH从入门到精通:密钥登录、config配置、跳板机
linux·运维·服务器·ssh
IT大白鼠3 天前
AI SSH 运维助手 V13.0内部版七项私有新特性全解
运维·人工智能·ssh
微软技术分享3 天前
NexShell 1.0|大模型驱动的智能 SSH 运维终端,永久免费,赋能 Linux 服务器管理
运维·服务器·ssh
小白的码BUG之路3 天前
linux -- ssh两台机器相连
运维·服务器·ssh
小白的码BUG之路4 天前
Jenkins -- 配置ssh
运维·ssh·jenkins
T0uken5 天前
Colab:SSH 访问免费 GPU Server
运维·ssh
GPU实战笔记5 天前
PyCharm 接云 GPU:远端项目连接与远程解释器别混为一谈
python·pycharm·ssh·远程开发·云gpu