问题背景:Windows 上 bat 脚本调用 SSH 无法自动输入密码

Windows 生成无密码密钥

ssh-keygen -t ed25519 -N "" -f %USERPROFILE%\.ssh\id_ed25519

查看公钥内容:

type %USERPROFILE%\.ssh\id_ed25519.pub

复制输出内容。

Linux 配置公钥登录

mkdir -p ~/.ssh
chmod 700 ~/.ssh
echo '复制的公钥内容' >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

Windows 测试免密登录

ssh user@服务器IP

无需密码即成功。

Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐