Skip to content

Instantly share code, notes, and snippets.

1、罗列式

[code] for VARIABLE in 1 2 3 4 5 .. N do command1 command2 commandN done [/code]

What is Ip address?

An IP address is the identifier that enables our device to send or receive data packets across the internet. It holds information related to our location and therefore making devices available for two-way communication.

Most internet service providers still use IPv4. It’s based on 32 binary bits, consists of four numbers from 0 to 255, and is separated by dots. For example, 103.86.98.1.

Check Ip address with ip addr command

ip addr – Show information for all addresses ip addr show dev em1 – Display information only for device em1

Get Ip address with ifconfig command

The “ifconfig” command is another most common command used to view IP related information.

This post describes how to see TCP connection establishment and termination as packets using tcpdump on linux.

Preparing
Install following commands on your linux.
\

  • tcpdump \
  • nc \
  • telnet \
  • netstat
    \
Get list length in Python 3 Examples
len() function list = [10, 20, 30]
n = len(list)
print(“The length of list is: “, n)
for loop list = [‘Python’,’Java’,’Kotlin’,’Machine Learning’,’Keras’]
size = 0
print(“Length of the input string:”)
for x in list:
size+=1
print(size)
len() function for nested list nestedList = [‘Krishna’, 20,’John’, [20, 40, 50, 65, 22], ‘Yung’, 11.98]print(“Original List = “, nestedList)print(“Length of a Nested List =

linux 最常用的查看mac地址的方式 有很多种,下面给出4种方式,

ifconfig 这是最常用的方式

ip link show

cat /sys/class/net/eth0/address 查看eth0的mac地址

dmesg | grep eth0

how to check mac address in Linux

Der 、Cer、 Pfx、 Pem它们都是扩展名(文件名的后缀,代表格式)

.DER:用二进制DER编码的证书;.PEM:用ASCLL(BASE64)编码的证书; .CER:存放公钥,没有私钥; .PFX:存放公钥和私钥(pem 后缀的证书都是base64编码;der 后缀的证书都是二进制格式;crt .cer 后缀的文件都是证书文件(编码方式不一定,有可能是.pem,也有可能是.der);.pfx 主要用于windows平台,浏览器可以使用,也是包含证书和私钥,获取私钥需要密码才可以)

X509文件扩展名(x509 这种证书只有公钥,不包含私钥。)

编码(也用作扩展)

DER = DER扩展用于二进制DER编码证书。这些文件也可能带有CER或CRT扩展名。正确的英语用法是“我有DER编码证书”而不是“我有DER证书”。

find命令特点:文件查找,实时查找,速度略慢,精确匹配

使用格式:# find [options] [查找路径] [查找条件] [处理动作]

查找路径:默认为当前目录

查找条件:默认为查找指定路径下的所有文件

处理动作:默认为显示

什么是known_hosts文件

A通过ssh首次连接到B,B会将公钥1(host key)传递给A,A将公钥1存入known_hosts文件中,以后A再连接B时,B依然会传递给A一个公钥2,OpenSSH会核对公钥,通过对比公钥1与公钥2 是否相同来进行简单的验证,如果公钥不同,OpenSSH会发出警告, 避免你受到DNS Hijack之类的攻ji。。

打开known_hosts文件

vi ~/.ssh/known_hosts 或 vi /root/.ssh/known_hosts host文件内容格式:ip 公钥

了解更多ssh known_host

insert()往列表的指定位置添加元素,举个例子:

insert的列子

1 a = ["hello", "world", "dlrb"] 2 a.insert(1, "girl") 3 print(a) 输出结果:

['hello', 'girl', 'world', 'dlrb']

本文对SSH连接验证机制进行了非常详细的分析,还详细介绍了ssh客户端工具的各种功能,相信能让各位对ssh有个全方位较透彻的了解,而不是仅仅只会用它来连接远程主机。

1.1 非对称加密基础知识

对称加密:加密和解密使用一样的算法,只要解密时提供与加密时一致的密ma就可以完成解密。例如QQ登录密ma,银行卡密ma,只要保证密ma正确就可以。

非对称加密:通过公钥(public key)和私钥(private key)来加密、解密。公钥加密的内容可以使用私钥解密,私钥加密的内容可以使用公钥解密。一般使用公钥加密,私钥解密,但并非绝对如此,例如CA签署证书时就是使用自己的私钥加密。在接下来介绍的SSH服务中,虽然一直建议分发公钥,但也可以分发私钥。