linux练习

1.https的原理

HTTP缺点

(1)通信使用明文,不加密,内容可能会被窃听;
(2)不验证通信方的身份,因此有可能遭遇伪装;
(3)无法证明报文的完整性,所以有可能已遭篡改。

HTTPS

HTTP通过和SSL(Secure Socket Layer,安全套接层)或TLS(Transport Layer Security,安全层传输协议)的组合使用,加密HTTP的通信内容。即用SSL建立安全通信线路,然后再在这条线路上进行HTTP通信。与SSL组合使用的HTTP被称之为HTTPS(HTTP Secure,超文本传输安全协议)或HTTPover SSL
详细过程不再具体描述了,推荐看这篇https://blog.51cto.com/11883699/2160032,写的很详细。这边我简单举一个用户访问淘宝的例子来总结https的通讯过程
(1)用户输入网址通过浏览器向淘宝服务器发送访问的请求
(2)淘宝服务器向客户端浏览器发送含有公钥的证书
(3)客户端浏览器验证证书是否可靠,验证通过后,提取公钥。接着客户端生成对称秘钥和要使用的加密算法等信息,用淘宝的公钥加密后,发送给淘宝服务器
(4)淘宝服务器用自己的私钥解开得到对称秘钥和加密算法
(5) 此后服务器和客户端的通信数据需要通过该对称秘钥及加密算法加密后,才能相互发送

2.centos7开机流程

(1)UEFi或BIOS初始化,运行POST开机自检
(2)选择启动设备
(3)引导装载程序, centos7是grub2
(4)加载装载程序的配置文件:/etc/grub.d/ /etc/default/grub /boot/grub2/grub.cfg
(5)加载initramfs驱动模块
(6)加载内核选项
(7)内核初始化,centos7使用systemd代替init
(8)执行initrd.target所有单元,包括挂载/etc/fstab
(9)从initramfs根文件系统切换到磁盘根目录
(10)systemd执行默认target配置,配置文件/etc/systemd/system/default.target
(11)systemd执行sysinit.target初始化系统及basic.target准备操作系统
(12)systemd启动multi-user.target下的本机与服务器服务
(13)systemd执行multi-user.target下的/etc/rc.d/rc.local
(14)Systemd执行multi-user.target下的getty.target及登录服务
(15)systemd执行graphical需要的服务

3.用shell脚本实现自动配置rsync服务

[root@centos7 bin]vim rsync.sh
#!/bin/bash
rsync  -avz /etc 192.168.48.128:/tmp
[root@centos7 bin]vim /etc/crontab
@daily root /root/bin/rsync.sh

4.使用netcat实现从一台机器直接登录到另外一台机器

两台机上编译安装好netcat
[root@centos7 ~]cd /app/httpd24/
[root@centos7 httpd24]netcat -l -p 10000 -e /bin/bash
[root@centos6 ~]netcat 192.168.48.129 10000
ls(这是要输入的命令)
bin
build
cgi-bin
error
htdocs
icons
include
logs
man
manual
modules

5.用shell脚本实现自动登录机器

(1)编写脚本

[root@centos7 bin]vim autologin.exp
#!/usr/bin/expect                                                                                             
set ip [lindex $argv 0]
set user [lindex $argv 1]
set password [lindex $argv 2]
spawn ssh $user@$ip
expect {
    "yes/no" { send "yes\n";exp_continue }
    "password" { send "$password\n" }
}
interact

(2)测试脚本

[root@centos7 bin]autologin.exp 192.168.48.128 root aabbcc
spawn ssh [email protected]
[email protected]'s password: 
······
[root@centos6 ~]exit
logout
Connection to 192.168.48.128 closed.

你可能感兴趣的:(linux练习)