wsl openssh安装

1、卸载openssh

sudo apt remove openssh-server

2、设置软件源
修改/etc/apt/sources.list为下面内容,使用vi时先按下i再粘贴,不然格式是乱的
然后suo apt-get update

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

3、安装
sudo apt install openssh-server
提示
openssh-server : Depends: openssh-client (= 1:6.6p1-2ubuntu2.13) but 1:7.6p1-4ubuntu0.3 is to be installed

sudo apt install openssh-server

4、修改sshd_config

sudo sed -i '/PermitRootLogin /c PermitRootLogin yes' /etc/ssh/sshd_config
sudo sed -i '/PasswordAuthentication /c PasswordAuthentication yes' /etc/ssh/sshd_config
sudo sed -i '/Port /c Port 221' /etc/ssh/sshd_config

5、重启ssh
sudo systemctl start sshd的时候
System has not been booted with systemd as init system (PID 1). Can't operate.
可使用

sudo /etc/init.d/ssh restart

或者

 sudo service ssh restart
posted @ 2022-07-07 10:15  zhaogaojian  阅读(24)  评论(0编辑  收藏  举报