“CentOS服务搭建-03-开启SSH服务”的版本间的差异

来自DeerGrove Wiki
跳转至: 导航搜索
(Administrator移动页面Ubuntu上开启SSH服务Centos开启SSH服务
(没有差异)

2021年12月15日 (三) 13:26的版本


SSH 是为建立在应用层基础上的安全协议。SSH 是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议。利用 SSH 协议可以有效防止远程管理过程中的信息泄露问题。如果没有开启ssh无法进行远程连接终端。

  1. 查看是否开启了ssh服务是否安装,使用命令:sudo ps -e |grep ssh //如果安装了的是会有sshd服务的
  2. 先更新资源列表,使用命令:sudo apt-get update
  3. 安装openssh-server,使用命令:sudo apt-get install openssh-server
  4. 继续输入sudo ps -e |grep ssh查看是否安装成功。
  5. 启动SSH服务:sudo /etc/init.d/ssh start
  • 修改SSH配置文件。可以通过SSH配置文件更改包括端口、是否允许root登录等设置,配置文件位置:/etc/ssh/sshd_config
  • 默认是不允许root远程登录的,可以再配置文件开启。sudo vim /etc/ssh/sshd_config
找到PermitRootLogin without-password 修改为PermitRootLogin yes
  • 重启SSH服务:service sshd restart
  • 连接Ubuntu,出现错误:Failed SSH Key Exchange/提示key exchange failed.这是密匙交换错误,说明Ubuntu还没有打开密匙交换的配置。
  1. 打开配置文件进行编辑:vim /etc/ssh/ssh_config
  2. 去掉前面的注释符,使用22端口。
    • port 22
    • protocol 2
    • Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
    • MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
  3. 使用vi /etc/ssh/sshd_config打开并修改服务器端的配置文件。
  4. 在protocol 2 下面粘贴:
    • Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
    • MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
  5. 然后重启sshd服务:service sshd restart