windows本地运行这个bash脚本一次就行了
#!/bin/bash
# 生成密钥
echo "Generating SSH key pair..."
ssh-keygen -t rsa -f ~/.ssh/id_rsa -q -P ""
# 读取目标服务器的IP地址、端口和用户名
echo "Enter the remote server's IP address:"
read ip_address
echo "Enter the remote server's SSH port (default is 22):"
read port
port=${port:-22}
echo "Enter your username on the remote server:"
read username
# 将公钥复制到远程服务器
echo "Copying public key to remote server..."
cat ~/.ssh/id_rsa.pub | ssh -p $port $username@$ip_address "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"
echo "SSH key pair setup complete."