陈旭华

用一生勤奋,告诉自己不是小幸运

Ubuntu 安装 OpenSSH-Server

2019-12-14

桌面版 Ubuntu 默认是没有安装 SSH 服务的,需要手动安装服务:

  1. 更新源:sudo apt-get update

  2. 安装服务:sudo apt-get install -y openssh-server

  3. 确认服务是否顺利启动:ps -e | grep sshd

常见报错

「Could not get lock /var/lib/apt/lists/lock /var/lib/dpkg/lock」问题解决方法

E: Could not get lock /var/lib/apt/lists/lock - open (11: Resource temporarily unavailable)
E: Unable to lock directory /var/lib/apt/lists/
E: Could not get lock /var/lib/dpkg/lock - open (11: Resource temporarily unavailable)
E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

上述报错意思是进行 apt-get 操作时被 lock 住了,出现这个问题可能是有另外一个程序正在运行,导致资源被锁不可用(大概率是上次运行安装或更新时没有正常结束),进而出现此状况,解决的办法其实很简单,在终端中敲入以下命令:

sudo rm /var/lib/apt/lists/lock
sudo rm /var/lib/dpkg/lock

执行完成后,再次更新一下就可以了。

sudo apt-get update