一、安装
1.1、检查ssh是否已经安装
方式一
[root@localhost ~]# rpm -qa|grep ssh
方式二
[root@localhost ~]# ssh -version
1.2、使用yum进行安装(必须可以连网)
- 查看一下和ssh相关的安装包
[root@localhost ~]# yum search ssh
- 安装openssh
[root@localhost ~]# yum install -y openssh-*
二、测试
2.1、配置ssh服务
- 备份原始配置文件
[root@localhost ~]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config.ori
- 修改配置文件
[root@localhost ~]# vim /etc/ssh/sshd_config
- 修改内容如下:
Port 52113
#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::
#禁止root远程登录:
#LoginGraceTime 2m
PermitRootLogin no
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#禁止DNS:
UseDNS no
#UseDNS yes
#不允许密码登录:
PermitEmptyPasswords no
#PermitEmptyPasswords no
- 检查是否修改正确
[root@localhost ~]# vimdiff /etc/ssh/sshd_config.ori /etc/ssh/sshd_config
2.2、启动SSH服务
- 启动
[root@localhost ~]# service sshd start
或者
[root@localhost ~]# /etc//sshd start
- 有需要可以设置为开机启动
[root@localhost ~]# chkconfig --level 35 sshd on
[root@localhost ~]# chkconfig --list sshd