sudo apt install openssh-server
sudo ps -e |grep ssh # 显示sshd即安装成功
# start ssh service
$ sudo service ssh start
# restart ssh service
$ sudo service ssh restart
sudo vim /etc/ssh/sshd_config
修改端口等配置,修改完成后重启服务。
如果安装时遇到以下问题:
openssh-server : Depends: openssh-client (= 1:7.2p2-4ubuntu2.1) Depends: openssh-sftp-server but it is not going to be installed Recommends: ncurses-term but it is not installable Recommends: ssh-import-id but it is not installable E: Unable to correct problems, you have held broken packages.
原因如下:
openssh-server 依赖于 openssh-client , 而自带的openssh-client 与所要安装的 openssh-server 所依赖的版本不同
所以要安装对应版本的 openssh-client (报错信息括号内就是),来覆盖掉 Ubuntu 自带的版本
sudo apt install openssh-client=1:7.2p2-4ubuntu2.1
再安装openssh-server就可以成功了。