首先update

在apt-get update时出现如下错误

Ubuntu16.04 server 安装ssh问题解决办法-LMLPHP

问题原因

1. apt源问题

更换apt源,我选的阿里源,修改/etc/apt/source.list为如下代码:

# deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ - Release amd64 (20160420.1)]/ xenial main restricted
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse

然后再执行sudo apt-get update命令。

2.无法添加新的 CD-ROM 问题

这个错误的原因是cdrom已经被包含在源之中。要修复这个问题,我们需要将它从软件源中移除。

输入命令 vi /etc/apt/source.list,修改文件最上方部分的一行代码

deb cdrom:[elementary OS 0.3_Freya_–Daily amd64 (20150208)]/ trusty main restricte

在其前面加#号注释,然后运行apt-get update。问题应该已经解决。

安装sshd

输入以下命令:

       sudo service sshd status

若返回Active: inactive (dead)提示,

说明已安装sshd,但未开启,输入命令

       sudo service sshd start

然后再次输入命令

       sudo service sshd status

若出现如下提示

       Active: active (running) since Mon 2019-01-014 20:20:15 CST; 40s ago

则说明已ssh服务已启动。如果失败则卸载(sudo apt-get –purge remove sshd)重新安装,在第一次输入

       sudo service sshd status

返回提示Loaded: error (Reason: No such file or directory)时也需安装ssh

安装输入命令

       sudo apt-get install sshd或者sudo apt-get install openssh-server

然后按照提示安装即可。

 

参考博客:

https://blog.csdn.net/java_dotar_01/article/details/76942563

https://www.cnblogs.com/mufire/p/6433757.html

https://blog.csdn.net/lingfengliujian/article/details/78299497

01-18 11:54