1. 本地要执行ssh的机器
ssh-keygen -t rsa
# 下面为对应密钥生成地址 公钥(id_rsa.pub)和私钥(id_rsa)。
# windows: C:\Users\<your_username>\.ssh
# linux: /home/service/.ssh
2. 讲密钥写入到对应文件
linux
ssh-copy-id <user>@<ip>
windows:将公钥传入到对应linux上
~/.ssh/authorized_keys
# your_public_key_here为你的公钥
echo "your_public_key_here" >> ~/.ssh/authorized_keys