目录
1.实现免密登录
[root@rhcsa01 ~]# cd .ssh/
[root@rhcsa01 .ssh]# ssh-keygen -t rsa
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
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:
SHA256:0zyRYAz/oV5/5jamaWYeM8R4aoQdd4QZnL7A/2YT4eM root@rhcsa01
The key's randomart image is:
+---[RSA 3072]----+
| .oo ..=. |
| o.. .=. |
| ..=.. . |
| BoB... |
| S Xo+o . |
| . + *o + |
| . o =ooo |
| . +OE |
| =+*.o |
+----[SHA256]-----+
[root@rhcsa01 .ssh]# ls -l
-rw-------. 1 root root 2602 Jul 25 16:27 id_rsa
-rw-r--r--. 1 root root 566 Jul 25 16:27 id_rsa.pub
[root@rhcsa01 .ssh]# ssh-copy-id root@192.168.168.128
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
The authenticity of host '192.168.168.128 (192.168.168.128)' can't be established.
ECDSA key fingerprint is SHA256:N2/KlwvovK5JROJKyl4Ea1TTsyvcjCJOrSJNjTeRPSE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.168.128's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'root@192.168.168.128'"
and check to make sure that only the key(s) you wanted were added.
[root@rhcsa01 .ssh]# cat authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDPuAdsNY9vyqo4HgM7fjnuT17uaQWOJHQDSrqQGIf5TJ5B22i0UhJbSxUr2pKHyqfs3wSlhF2eDe/Sni/xmUFIntR4QWb92D6eSyKl7AOeDhRaN1jdldqbjLTv0SG1bZldP5CGUfV7yiC2mWjmEt0SDFjsRaOJOzm9kvHk1lEx3UI+pgSuC/3LoQ1wTtz8wqaQOPqmHUpIjVpVJp81vgSnJkh6/6WuuAxVtKGRCmi6zc2pv8+Rt8PlzBtQMjUtKL8FetwkUrte4suXU+egEc0EN5GnEjaZ/PR4wxm3yK9HH2vdzAD7nwIpMxjMij+KPWsS2s8d1bydPvZzLr6qkG1Ny1wv6mAzE1/jQxIiEVypK/OKeYyKLw1QMaDysZwmYErbHhRqKRCHfWaGgPFjIqSsfYUmU/MOZLEquy+KPCKUm9ea0sDqmbEou2CtdlDZuWO1PiW/6iHwC0MmFe5HJXEekuCO0vz5kgtVn+urZfeQgmtpDHz/IlJbSEDTE1h53wU= root@rhcsa01
[root@rhcsa01 .ssh]# ssh root@192.168.168.128
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Mon Jul 25 16:16:46 2022 from 192.168.168.1
[root@rhcsa01 ~]# 免密登录成功
2.设置只允许student1, student2用户登录
(1)创建student1,student2,设置密码
[root@rhcsa01 ~]# useradd student1
[root@rhcsa01 ~]# passwd student1
Changing password for user student1.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@rhcsa01 ~]# useradd student2
[root@rhcsa01 ~]# passwd student2
Changing password for user student2.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
(2)进入文件,添加配置
UsePAM yes
#AllowAgentForwarding yes
#AllowTcpForwarding yes
Allowusers student1
Allowusers student2
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
(3)用student1,通过ssh登录到目标服务器
[root@rhcsa01 ~]# su student1
[student1@rhcsa01 root]$ ssh root@192.168.168.128
The authenticity of host '192.168.168.128 (192.168.168.128)' can't be established.
ECDSA key fingerprint is SHA256:N2/KlwvovK5JROJKyl4Ea1TTsyvcjCJOrSJNjTeRPSE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.168.128' (ECDSA) to the list of known hosts.
root@192.168.168.128's password:
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Mon Jul 25 16:48:05 2022
(4)用student2,通过ssh登录到目标服务器
[root@rhcsa01 ~]# su student2
[student2@rhcsa01 root]$ ssh root@192.168.168.128
The authenticity of host '192.168.168.128 (192.168.168.128)' can't be established.
ECDSA key fingerprint is SHA256:N2/KlwvovK5JROJKyl4Ea1TTsyvcjCJOrSJNjTeRPSE.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.168.128' (ECDSA) to the list of known hosts.
root@192.168.168.128's password:
Activate the web console with: systemctl enable --now cockpit.socket
This system is not registered to Red Hat Insights. See https://cloud.redhat.com/
To register this system, run: insights-client --register
Last login: Mon Jul 25 16:48:50 2022 from 192.168.168.128
3.get和post的区别
分类 | get | post |
后退按钮/刷新 | 无害 | 数据会被重新提交 |
书签 | 可收藏为书签 | 不可收藏为书签 |
缓存 | 能被缓存 | 不能被缓存 |
编码类型 | application/x-www-form-urlencoded | application/x-www-form-urlencoded 或 multipart/form-data 为二进制数据使用多重编码 |
历史 | 参数保留在浏览器历史中 | 参数不会保存在浏览器历史中 |
对数据长度的限制 | 当发送数据时,GET 法向URL添加数据;URL 的长度是受限制的 | 无限制 |
对数据类型的限制 | 只允许 ASCII 字符 | 没有限制(允许二进制数据) |
安全性 | 较差 | 更安全 |
可见性 | 数据在 URL 中对所有人都可见 | 数据不会显示在 URL 中 |
4.HTTP状态码,常用的状态码有哪些?
1xx:信息状态码
100(继续请求):客户端在发起POST请求给服务器端,征询服务区的情况,查看服务器是否处理POST的数据
2xx:成功状态码
200(成功):请求已成功,请求所希望的响应头或者请求体数据将随此响应返回
201(已创建):请求成功并且服务器创建了新的资源
202(已创建):服务器已经接收请求,但尚未处理
203(未授权信息):服务器已成功处理请求,但是返回的数据可能来自另一来源
204(无内容):请求已经成功,但是没有返回任何内容
205(重置内容):服务器成功处理请求,但是没有返回内容
206(部分内容):服务器成功处理了部分的请求
3xx:重定向状态码
301(永久移动):请求的页面已经被永久移动到新位置。服务器返回此响应时,会自动将请求者转到新的位置
302(临时移动):服务器目前从不同位置的页面响应请求,但请求者应继续使用原有位置来进行以后的请求
303(查看其他位置):请求者应该对不同的位置使用单独的 GET 请求来检索响应,服务器返回此代码
304(未修改):上次请求之后,请求的页面没有修改过。服务器返回此响应,不会返回网页内容
305(使用代理):请求者只能使用代理访问请求的网页,如果服务器返回此响应,表示请求者应该继续使用代理
4xx:客户端错误状态码
400(错误请求):服务器不理解请求的语法
401(未授权):请求要求身份验证。对于需要登录的页面,服务器返回此状态码
403(禁止):服务器拒绝请求
404(未找到):服务器找不到要请求的网页
405(方法禁用):禁止请求中指定的方法
406(不接受):无法使用请求的内容特来响应请求的网页
407(需要代理授权):与401类似,但指定请求者应当授权使用代理
408(请求超时):服务器在等候请求时发生超时
5xx:服务器错误状态码
500(请求错误):服务器遇到错误,无法完成请求
501(尚未实施):服务器不具备完成请求的功能
503(服务不可用):服务器目前不可用(超载或者停机维护)
504(网关超时):服务器作为网关/代理,但是没有及时从上游服务器收到请求
505(http版本不支持):服务器不支持请求中所用到的 HTTP 协议版本
5.HTTP请求报文和响应报文
(1)HTTP的请求报文
(2)HTTP的响应报文
6.HTTP是如何保持连接状态的
Cookie保持状态
Session
网址重写(URL rewriting)
隐藏域