Linux unit9

简介:

1.openssh-server

功能:让远程主机可以通过网络访问sshd服务,开始一个安全shell

 

2.客户端连接方式

ssh 远程主机用户@远程主机ip -X##调用远程主机图形工具

ssh远程主机用户@远程主机ip       ssh root@172.25.0.11自己的ip

wKioL1jsns7is50gAAB3_fQ5hKY506.png-wh_50 

ssh     远程主机用户@远程主机ipcommand##直接在远程主机运行某条命令

 wKiom1jsnt6yVcc9AAEIqonV_d0842.png-wh_50

3.sshkey加密

1生成公钥私钥        ssh-keygen ##生成公钥私钥工具

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):[enter] ##加密字符保存文件(建议用默认)

Created directory '/root/.ssh'.

Enter passphrase (empty for no passphrase): [enter]##密钥密码,必须>4个字符

Enter same passphrase again: [enter]##确认密码

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

ab:3c:73:2e:c8:0b:75:c8:39:3a:46:a2:22:34:84:81 root@server0.example.com

The key's randomart image is:

+--[ RSA 2048]----+

|o                |

|E.               |

|..               |

|.  . o           |

|.o. * . S        |     

|oo.o o   .       |

|+ =. .  .        |

|o. oo.+..        |

|    ..o*.        |

+-----------------+

 wKioL1jsnxXAIhdNAAHkjl6FUOA877.png-wh_50

 

[root@server0 ~]# ls /root/.ssh/

id_rsa##私钥,就是钥匙

id_rsa.pub##公钥,就是锁

 wKiom1jsnyrRy_HzAABTJ3LpjI8613.png-wh_50

2添加key认证方式   ssh-copy-id ##添加key认证方式的工具   -i##指定加密key文件

加密命令: ssh-copy-id -i /root/.ssh/id_rsa.pub  root@172.25.0.11

/root/.ssh/id_rsa.pub##加密key    root##加密用户为root

172.25.0.11##被加密主机ip

 wKioL1jsn0zh6LbUAAJ9Cu5pJos314.png-wh_50

3分发钥匙给client主机

命令: scp /root/.ssh/id_rsa root@172.25.0.10:/root/.ssh/

 wKiom1jsn16Rx9BFAAGkN5l5Vtk055.png-wh_50

4测试

 

[root@desktop0 ~]# ssh root@172.25.0.11##通过id_rsa直接连接不需要输入用户密码

Last login: Mon Oct  3 03:58:10 2016 from 172.25.0.250

[root@server0 ~]#

 wKioL1jsn2-Sa4W0AABco6G-_b8136.png-wh_50

4.提升openssh的安全级别

1openssh-server配置文件

/etc/ssh/sshd_config

78 PasswordAuthentication yes|no##是否开启用户密码认证,yes为支持no为关闭

wKiom1jsn4qy3MHHAABHmDLIbqw352.png-wh_50

48 PermitRootLogin yes|no##是否允许超级用户登陆

wKiom1jsn6GSveW4AABC_xEvMhM839.png-wh_50

49 AllowUsers student westos##用户白名单,只有在名单中出现的用户可以使用sshd建立shell

50 DenyUsers westos##用户黑名单


本文转自 AELY木 51CTO博客,原文链接:http://blog.51cto.com/12768057/1914964,如需转载请自行联系原作者

相关文章
|
7月前
|
Linux
17.1.2 【Linux】systemd使用的unit分类
17.1.2 【Linux】systemd使用的unit分类
73 0
|
设计模式 监控 网络协议
关于Linux中通过 Systemd Path Unit 监听配置更新自动重启服务的一些笔记
在 stackoverflow.com 的Unix & Linux 社区 看到有小伙伴提出相关的问题。 这里整理分享给小伙伴,博文内容涉及: Systemd 的 Path Units常用命令手册学习 Path Units 的应用 通过httpd服务演示监听配置文件自动重启服务 食用方式:需要了解一点 Systemd 理解不足小伙伴帮忙指正
205 0
|
Linux 开发工具 Shell
|
监控 Unix 测试技术
|
网络协议 Linux 开发工具
|
Web App开发 Linux 开发工具