美文网首页
ssh(secure shell) on hands

ssh(secure shell) on hands

作者: ikexin | 来源:发表于2018-04-01 16:36 被阅读0次

安装命令

          RedHat,CentOS(PRM版本):    yum install openssh-server openssh-client

          Debian,Ubuntu(DEB版本):     apt-get openssh-server openssh-client

         SSH常用配置选项

SSH配置

1.基于口令的认证方式: ssh options username@hostname 'command'

2.基于密钥的认证方式:

a) ssh-keygen命令生成公钥和私钥. 

b) 将公钥文件加入主机的认证文件中 

    cat id_rsa.pub >> ~/.ssh/authorized_keys

    chmod 600 authorized_keys

    拷贝id_rsa.pub到客户端

    如果是windows客户端,需要用putty工具对key文件        转换城.ppk格式

注意.ssh目录权限为700,authorized_keys文件为600

3.访问策略 限制用户连接SSH

/etc/ssh/sshd_config

a) DenyUsers test

b)AllowUsers test

c)DenyGroups test

d) AllowGroups test

新建用户: useradd test,passwd test

显示test用户登陆:vim /etc/ssh/sshd_config,service,添加Denyusres test

重启sshd:service sshd restart

4.访问策略,限制IP连接SSH

a) 只基于端口的限制 iptables -A INPUT -p tcp --dport 22 -s 192.168.0.10/32 -j ACCEPT

  iptables -A INPUT -p tcp --dport 22 -j DROP

b) TCP Wrapper

vim /etc/hosts.allow       sshd:192.168.0.10/255.255.255.255

vim /etc/hosts.deny    sshd:ALL EXCEPT 192.168.0.10

相关文章

网友评论

      本文标题:ssh(secure shell) on hands

      本文链接:https://www.haomeiwen.com/subject/rwdkcftx.html