在Ubuntu 18.04系统中启用SSH登录的方法

Port 2222 # 默认 22 已占用,换为 2222 UsePrivilegeSeparation no # yes -> no # 允许 root 账户登陆,需要使用 Xshell 登陆 root 账户的话修改为 yes PermitRootLogin yes PasswordAuthentication yes # no -> yes

报错

Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 openssh-server : Depends: openssh-client (= 1:7.2p2-4ubuntu2.6) but 1:7.6p1-4 is to be installed
E: Unable to correct problems, you have held broken packages.

解决:

 sudo apt-get remove openssh-client

sudo apt-get install openssh-server

sudo service ssh restart

sudo service ssh status

 

不要忘了,还要配置防火墙开启端口才能被其他PC访问

打开 Win10 防火墙设置,(可以通过右下角有个向上的箭头点击盾牌快速进入面板)Windows Defender 安全中心,点击下方的高级设置

 

本文教你在Ubuntu 18.04系统中启用SSH登录,实测成功。Secure Shell(SSH)是Linux系统管理中的经常要用到的一种远程访问技术。在Ubuntu 18.04系统仓库中,已经收录了同为开源的OpenSSH,我们可以用它来为系统开启SSH访问功能。

 

具体方法:

一、打开终端,输入以下命令安装OpenSSH服务:

sudo apt-get install openssh-server

 

二、步骤一的作用是在当前系统增加SSH服务,接下去可以用命令:sudo service ssh status 检查一下服务的状态。

如果需要对SSH服务修改设置,可以用字处理工具编辑其配置文件,位于“ /etc/ssh/sshd_config”,比如用vim修改的命令就是:

sudo nano /etc/ssh/sshd_config

 

三、初次安装后,其实SSH并没有自动运行,可以用server命令来启动,例如:

sudo service ssh restart

 

四、安装完成之后,就可以在客户端用系统用户来远程登录了。

例如在Windows系统下可以用Putty之类软件,在Linux中则可以使用openssh-client,可以用命令来安装:

sudo apt-get install openssh-client。

 

成功图:

在Ubuntu 18.04系统中启用SSH登录的方法

参考文献:

https://ywnz.com/linuxjc/2347.html

https://www.jianshu.com/p/5cf6849aa28f

 

https://blog.csdn.net/zhouzme/article/details/81087837