ubuntu18.04安装ssh-server服务器和openssh-client客服端(2021-5-12)

步骤1:安装ssh-server

//命令
sudo apt-get install openssh-server

步骤2:安装ssh-client

//命令
sudo apt-get install openssh-client

步骤3:确认sshserver是否安装好

root@xfj-virtual-machine:/usr/local/arm/arm-2009q3/bin# ps -e | grep sshd
  5831 ?        00:00:00 sshd

//执行命令启动ssh服务
root@xfj-virtual-machine:/usr/local/arm/arm-2009q3/bin# /etc/init.d/ssh start
[ ok ] Starting ssh (via systemctl): ssh.service.

注意:如果看到sshd那说明ssh-server已经启动了。
如果只有ssh-agent说明ssh-server还没有启动,需要执行命令启动ssh服务:
/etc/init.d/ssh start;

步骤4:更改服务端口

//SSH默认服务端口为22,用户可以自已定义成其他端口,如222,需要修改的配置文件为:/etc/ssh/sshd_config
//把里面的Port参数修改成222即可
 13 #Port 22                        //将前面的#去掉,然后将22更改为自定义服务端口即可
 14 #AddressFamily any
 15 #ListenAddress 0.0.0.0
 16 #ListenAddress ::



//然后重启SSH服务: 
//sudo /etc/init.d/ssh restart
root@xfj-virtual-machine:/usr/local/arm/arm-2009q3/bin# sudo /etc/init.d/ssh restart
[ ok ] Restarting ssh (via systemctl): ssh.service.           //即可

步骤5:使用SecureCRT连接ubuntu虚拟机,显示到会话连接失败

在这里插入图片描述

5.1 vi /etc/ssh/ssh_config 修改客户端的SSH配置

xfj@xfj-virtual-machine:~$ vim /etc/ssh/ssh_config        //命令
//38、39是其所在行的序号
//将这两行前面的#去掉,然后保存
 38 #   Port 22
 39 #   Protocol 2
 
//修改过的内容,保存
 38     Port 22
 39     Protocol 2
//去掉#复制这两行,将其复制到sshd_config服务器端的配置文件
 40 #   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
 41 #   MACs hmac-md5,hmac-sha1,umac-64@openssh.com

5.2使用vi sshd_config命令打开并修改服务器端的配置文件,之前修改的是客户端的

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
//放到此处即可
#**************************************************************************
    Ciphers aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc
    MACs hmac-md5,hmac-sha1,umac-64@openssh.com                 
#*************************************************************************

#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

5.3用service sshd restart 重启sshd服务

root@xfj-virtual-machine:/etc/ssh# service sshd restart          //回车

5.4验证使用SecureCRT连接ubuntu虚拟机,显示成功

在这里插入图片描述
在这里插入图片描述

步骤6 用sshsecureshell登录连接ubuntu虚拟机,显示到连接失败

在这里插入图片描述
在这里插入图片描述
没解决


版权声明:本文为xufujuning原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。