1.安装ssh服务端

sudo apt install openssh-server
sudo ps -e |grep ssh # 显示sshd即安装成功

2. SSH Service

# start ssh service
$ sudo service ssh start 
# restart ssh service 
$ sudo service ssh restart 

3. SSH Server Config

sudo vim /etc/ssh/sshd_config

修改端口等配置,修改完成后重启服务。

Troubleshooting

如果安装时遇到以下问题:

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就可以成功了。

OpenSSH Server | Ubuntu