[linux] redhat 7 ssh 安装&配置免密登录

安装ssh

yum install openssh

查看端口

netstat -ntpl

netstat -ntpl | grep :22

启动和关闭

service sshd restart/start/top     redhat6版本命令

systemctl restart/start/stop sshd redhat7版本命令

开机启动:

systemctl enable/disable sshd

ssh配置文件

/etc/ssh/sshd_config

PermitRootLogin yes/no   是否禁止root远程登录

将PermitRootLogin、RSAAuthentication、PubkeyAuthentication的设置打开。

注意:如果当前的Openssh在7.3+以上,RSAAuthentication需要如图注释掉,

因为这个配置只支持SSH Protocol version 1,Openssh 7.3+以上使用的是SSH Protocol version2。

ssh无密码连接方式:

客户端配置命令:

ssh-kengen   生成公钥和密钥

或 ssh-keygen -t rsa

生成成功后,会在/root/.ssh/目录下,产生两个文件id_rsa id_rsa.pub

ssh-copy-id /root/.ssh/id_rsa.pub 192.168.1.1 (服务端IP:192.168.3.1 ,把公钥cp到服务端的/root/.ssh/目录下)

ssh [email protected]   测试连接是否需要密码验证

authorized_keys文件存储的是客户端的公共密钥。

 

对ssh配置登陆策略

设置允许:

# vi /etc/hosts.allow

sshd:10.0.5.6  (10.0.0.0/24,*.ming.com)

:wq

设置拒绝:

# vi /etc/hosts.deny

sshd:10.0.0.3  (10.0.0.0/24,*.ming.com)

:wq

 

猜你喜欢

转载自blog.csdn.net/henku449141932/article/details/108765262