Ubuntu开启ssh服务,使得xshell和xftp能够远程连接

使用用xftp,xshell 远程登录需要ssh服务开启

如果没有安装openssh-server,则通过以下命令安装:

sudo apt-get install openssh-server 

启动ssh服务

sudo service ssh start

或者使用这个命令

/etc/init.d/ssh start

之后通过以下命令查看SSH是否启动:

ps -e | grep ssh 

开启后发现普通用户可以远程连接,但是连接root用户不行

Ubuntu默认没有设置root的密码,sudo passwd root,回车后按提示输入两次root的密码

root登录时显示ssh服务器拒绝了密码,请重新连接。

由于sshd的设置不允许root用户用密码远程登录,需要修改/etc/ssh/sshd_config文件

vim /etc/ssh/sshd_config

找到

#Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes1

改成如下:

即把PermitRootLogin prohibit-password注释掉,后面添加PermitRootLogin yes

#Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes1

然后退出vim编辑,重启ssh服务

/etc/init.d/ssh restart

就可以用root 登录了