- (1) Windows的CMD中执行:ssh-keygen -t rsa,执行过程中直接回车。
```
ssh-keygen -t rsa
```
- (2) 执行完后会在C:\Users\xxx\.ssh文件夹下生成如下三个文件:
- id_rsa是本地私钥
- id_rsa.pub是公钥
- known_hosts是已知的ip
- (1) 创建文件
```
mkdir ~/.ssh
sudo chmod 700 ~/.ssh
nano ~/.ssh/id_rsa.pub
```
- (2) 拷贝内容
- 把 windows C:\Users\xxx\.ssh\id_rsa.pub 文件内容拷贝
- (3) Ubuntu中执行
```
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
```
- Ubuntu中执行
```
sudo nano /etc/ssh/sshd_config
## 在最后一行添加
RSAAuthentication yes
PubkeyAuthentication yes
PasswordAuthentication no
```
```
sudo service sshd restart
```
windows 打开 cmd:ssh (用户名)@192.168.1.2(用自己的数据),如果没有提示输入密码,则配置成功。