Xz's blog Xz's blog
首页
时间序列
多模态
合成生物学
其他方向
生活
工具相关
PyTorch
导航站

Xu Zhen

首页
时间序列
多模态
合成生物学
其他方向
生活
工具相关
PyTorch
导航站
  • Rust

  • Rust-Windows 窗口自动化

  • Tauri

  • C++

  • Claude Code

  • Liunx相关

    • 进程相关命令
    • 免密登录
      • 步骤一:在 Windows 上生成 SSH 密钥对
      • 步骤二:将公钥复制到 Linux
      • 步骤三:测试免密登录
      • 补充配置(可选)
        • 修改 SSH 配置文件(Linux 上):
    • Linux 通过Windows代理上网
  • MAC相关

  • Windows相关

  • IDE

  • Conda

  • Docker

  • VMware虚拟机

  • Python常用代码片段

  • 工具相关
  • Liunx相关
xuzhen
2025-07-29
目录

免密登录

要实现从 Windows 免密登录 Linux,一般是通过 SSH 公钥认证(Public Key Authentication)。下面是详细步骤:


# 步骤一:在 Windows 上生成 SSH 密钥对

  1. 打开 PowerShell 或者 Git Bash。

  2. 执行命令生成密钥对(不要加密码):

    ssh-keygen
    
    1
  3. 按提示一路回车,默认会生成:

    • 公钥:C:\Users\你的用户名\.ssh\id_rsa.pub
    • 私钥:C:\Users\你的用户名\.ssh\id_rsa

[!note] 公钥例子 ssh-ed25519 xxxxxxx xuzhe@xz

# 步骤二:将公钥复制到 Linux

使用以下命令将公钥复制到 Linux 用户主目录下(需输入一次密码):

ssh-copy-id 用户名@Linux_IP地址
1

如果没有 ssh-copy-id 工具,可手动操作:

# 手动方式(Linux 端)
vim ~/.ssh/authorized_keys
# 将公钥复制过去
......
# 修改权限()
chmod 600 ~/.ssh/authorized_keys
chmod 700 ~/.ssh
1
2
3
4
5
6
7

如果没有 .ssh 文件夹可以先创建一个文件夹 mkdir ~/.ssh


# 步骤三:测试免密登录

在 Windows 上执行:

ssh 用户名@Linux_IP地址
1

如果直接登录成功,则表示配置成功,不再需要密码。


# 补充配置(可选)

# 修改 SSH 配置文件(Linux 上):

编辑 /etc/ssh/sshd_config,确保以下选项启用:

PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication yes   #(可以先保留,调试完后可设为 no)
1
2
3

然后重启 SSH 服务:

sudo systemctl restart sshd
1
#Linux
上次更新: 2025/08/14, 10:32:31

← 进程相关命令 Linux 通过Windows代理上网→

最近更新
01
MAC 好用软件
12-05
02
Linux 通过Windows代理上网
09-18
03
vscode远程使用copilot和codex(内网环境)
09-18
更多文章>
Theme by Vdoing | Copyright © 2025-2025 Xu Zhen | 鲁ICP备2025169719号
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式