Windows下在c:\Users\用户\.ssh\config文件中添加如下内容:
shell
Host remote
HostName 192.168.6.218
User root
Port 22
IdentityFile C:\Users\用户名\.ssh\id_ed25519
设置免密登录,在Windows下运行如下命令:
shell
ssh-keygen -t ed25519 -C "cursor"
生成私钥和公钥,然后把公钥id_ed25519.pub拷贝到远程的主机上192.168.6.218,然后执行
shell
[root@localhost ~]# cat id_ed25519.pub >> ~/.ssh/authorized_keys
[root@localhost ~]# chmod 600 ~/.ssh/authorized_keys
[root@localhost ~]# chmod 700 ~/.ssh
接下来在Windows下通过ssh远程连接主机192.168.6.218,这个时候需要输入一次密码,后面不需要再输入,接下来需要配置sshd_config
shell
[root@localhost archery]# vi /etc/ssh/sshd_config
#以下是增加的内容
AllowTcpForwarding yes
AllowAgentForwarding yes
[root@localhost archery]# systemctl restart sshd
否者会报错
shell
无法连接到远程扩展主机服务器 (错误: WebSocket close with status code 1006)