dig -t axfr 域名(比如: google.com) @谷歌内网DNS(不是公网DNS,即不是8.8.8.8...)
dig -t axfr google.com @10.8.6.4 >> /tmp/domain.txt
# stty: 修改终端命令行的相关设置
stty rows 50 cols 132
sed -i s@"iptables -I"@"#iptables -I"@g /etc/firewall.user
sed -i s@#iptables@iptables@g /etc/firewall.user
iptables -nvL
iptables -nL
vim /etc/sysconfig/iptables
tcpdump -i br-lan '((src host 10.*.*.*) and (udp dst port 53))'
root@WRT1900ACS-part1:~# tcpdump -i br-lan '((src host 10.*.*.*) and (udp dst port 53))' -c 1000 -w 20210521.pcap
tcpdump: listening on br-lan, link-type EN10MB (Ethernet), capture size 262144 bytes
1000 packets captured
1007 packets received by filter
0 packets dropped by kernel
root@WRT1900ACS-part1:~#
ps -ef |grep openvpn
pkill openvpn
pkill -HUP openvpn
# Linux pkill 用于杀死一个进程,与 kill不同的是它会杀死指定名字的所有进程,
# 类似于 killall 命令.
# kill 命令杀死指定进程 PID,需要配合 ps 使用,
# 而 pkill 直接对进程对名字进行操作,更加方便.
# 解压当前目录下所有的tar.gz文件
# https://www.jianshu.com/p/94f46ddc24a9
ls */*.gz | xargs -n1 gunzip
find /tmp -name "*" | xargs grep '27.*.*.76'
find /tmp/24 -name "*" | xargs grep '27.*.*.76'
find . -type f -size +800M -print0 | xargs -0 ls -lh
find / -type f -size +800M -print0 | xargs -0 ls -lh
lastb | grep "May 16" | awk '{print $3}' | sort | uniq -c | sort -nr | head -n 10
# http://blog.chinaunix.net/uid-20329764-id-5016539.html
今天查看了一下服务器,发现/var/log/btmp日志文件比较大,搜索一下,此文件是记录错误登录的日志,就是说有很多人试图使用密码字典登录SSH服务,此日志需要使用lastb程序打开.
通过此文件发现有几个IP总是试图登录,可以使用防火墙把它屏蔽掉.
命令如下:
iptables -A INPUT -i eth0 -s *.*.*.0/24 -j DROP
查看恶意IP试图登录次数:
lastb | awk '{ print $3}' | sort | uniq -c | sort -n
删除这个日志:
rm -rf /var/log/btmp
touch /var/log/btmp
---------------------------------------------
Last login: Sat Oct 17 16:07:09 2020 from blh05562.800best.net
[root@openvpn-qsh3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
12G 8.9G 2.2G 81% /
/dev/sda1 99M 13M 82M 14% /boot
tmpfs 1006M 0 1006M 0% /dev/shm
[root@openvpn-qsh3 ~]# find / -type f -size +800M -print0 | xargs -0 ls -lh
find: /proc/14373/task/14373/fdinfo/4: No such file or directory
find: /proc/14373/fdinfo/4: No such file or directory
-rw------- 1 root root 6.7G Oct 27 13:57 /etc/openvpn/nohup.out
-r-------- 1 root root 2.1G Oct 27 13:57 /proc/kcore
[root@openvpn-qsh3 ~]#
# tcpdump抓取CDP报文信息:
tcpdump -nn -v -i eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'
参考:"tcpdump - Cisco Discovery Protocol (CDP).docx"
tcpdump -w test.pcap -i eth0 ether proto 0x88cc
The Ethernet type for LLDP is 0x88cc, so the filter to see only LLDP packets is ether proto 0x88cc
tcpdump -nn -v -i br-lan -s 1500 -c 1 ether proto 0x88cc
CDP
## This will often show you the Cisco chassis switch, then use your firms asset management software to find the upstream switch.
## -s 1500 capture 1500 bytes of the packet (typical MTU size)
## ether[20:2] == 0x2000 - Capture only packets that are starting at byte 20, and have a 2 byte value of hex 2000
# tcpdump -v -s 1500 -c 1 'ether[20:2] == 0x2000'
..
Device-ID (0x01), length: 28 bytes: 'cs1009-xd1.change.net'
LLDP
## Switch:
# tcpdump -i eth0 -s 1500 -XX -c 1 'ether proto 0x88cc'
## Port and CDP Neighbor Info:
# tcpdump -v -s 1500 -c 1 '(ether[12:2]=0x88cc or ether[20:2]=0x2000)'
The following tcpdump command will sniff your network for Cisco Discovery Protocol information. Change eth0 to match your currently network interface.
# get information about Cisco Discovery Protocol
$ sudo tcpdump -nnvi eth0 -s 1500 -c 1 'ether[20:2] == 0x2000'
The following tcpdump command will sniff your network for Link Layer Discovery Protocol information. Change eth0 to match your currently network interface.
# get information about Link Layer Discovery Protocol
$ sudo tcpdump -nnvi eth0 -s 1500 -XX -c 1 'ether proto 0x88cc'
The last option show how to use an expression to combine the two filters.
# get information about CDP and LLDP
$ sudo tcpdump -nnvi eth0 -s 1500 -c 1 '(ether[20:2]=0x2000 or ether[12:2]=0x88cc )'
使用Linux服务器做网关时,如果ping内网IP通,ping外网IP不通,注意服务器上启用NAT
[root@openvpn-gz ~]# iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
[root@openvpn-gz ~]# service iptables save
Saving firewall rules to /etc/sysconfig/iptables: [ OK ]
[root@openvpn-gz ~]#
实例:ADSL 拨号上网的拓扑
echo "1" > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o ppp0 -j MASQUERADE
route del -net 0.0.0.0
route add default gw 10.65.76.1
route add -net 192.168.1.0 netmask 255.255.255.0 gw 192.168.1.1
route add default gw 10.0.0.254 就相当于route add -net 0.0.0.0 netmask 0.0.0.0 gw 10.0.0.254
ip route2 | OpenVPN新服务器删除场地网段路由命令:
ip route del 10.0.0.0/24
# 查出目前 nf_conntrack 的排名(推荐使用第一个):
$ cat /proc/net/nf_conntrack | awk '{print $7}' | cut -d "=" -f 2 | sort | uniq -c | sort -nr | head -n 50
$ cat /proc/net/nf_conntrack | cut -d ' ' -f 16 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 50
# Active Connections.txt
# 01 nf_conntrack table full, dropping packet.docx
# 02 nf_conntrack - table full, dropping packet.docx
# Active Connections - Get list of open connections.txt
# 统计里面的TCP连接的各状态和条数
cat /proc/net/nf_conntrack | awk '/^.*tcp.*$/ {sum[$6]++} END {for(status in sum) print status, sum[status]}'
# 四层协议类型和连接数
root@WRT1900:~# cat /proc/net/nf_conntrack | awk '{sum[$3]++} END {for(i in sum) print i, sum[i]}'
icmp 106
tcp 7074
udp 3739
root@WRT1900:~#
cat /proc/sys/net/netfilter/nf_conntrack_count
cat /proc/net/nf_conntrack | wc -l
cat /proc/net/nf_conntrack | awk '{print $7}' | cut -d "=" -f 2 | sort | uniq -c | sort -nr | head -n 15
Linksys WRT1900ACS / Netgear R7000-100PRS
dport:
cat /proc/net/nf_conntrack | cut -d ' ' -f 19 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
dst:
cat /proc/net/nf_conntrack | cut -d ' ' -f 17 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
src:
cat /proc/net/nf_conntrack | cut -d ' ' -f 16 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
cat /proc/net/nf_conntrack | awk '{print $7}' | cut -d "=" -f 2 | sort | uniq -c | sort -nr | head -n 10
WNDR3700v4:
dst:
cat /proc/net/nf_conntrack | cut -d ' ' -f 17 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
src:
cat /proc/net/nf_conntrack | cut -d ' ' -f 16 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
WNDRMAC:
/*
dst:
cat /proc/net/nf_conntrack | cut -d ' ' -f 16 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
src:
cat /proc/net/nf_conntrack | cut -d ' ' -f 15 | cut -d '=' -f 2 | sort | uniq -c | sort -nr | head -n 10
# 测试UDP端口是否开放.txt
# nc测试可能不准确,建议使用nmap测试TCP/UDP端口的通断
[root@kr-sg-test ~]# nc -vuz 42.11.12.13 123
Connection to 42.11.12.13 123 port [udp/ntp] succeeded!
结果证明UDP 123端口正常监听.
# By Ross
# nmap测试TCP端口是否开放:
nmap 10.*.*.* -p 10050 -Pn
nmap -sS 10.*.*.* -p 10050 -Pn
nmap -sT 10.*.*.* -p 10050 -Pn
# nmap测试UDP端口是否开放:
nmap -sU 202.96.128.86 -p 53 -Pn
netstat -an | grep "TIME_WAIT" | wc -l
# 既排除空行又排除注释行的命令:
cat /etc/zabbix/zabbix_proxy.conf | grep -v "^$" | grep -v "^#"
cat /etc/zabbix/zabbix_proxy.conf | grep -Ev "^$|#"
grep -Ev '^$|[#;]' /etc/zabbix/zabbix_proxy.conf
grep -Ev '^$|#' /etc/zabbix/zabbix_proxy.conf
grep -Ev '^$|#' filename
# OpenWRT一个网卡临时添加多个IP:
ifconfig br-lan:1 192.168.128.3 netmask 255.255.255.0 broadcast 192.168.128.255 up
ifconfig br-lan:1 down
Linux 一个网卡添加多个IP(临时添加):
ifconfig eth0:0 172.16.1.100 netmask 255.255.255.255 broadcast 172.16.1.255 up
ifconfig eth0:1 192.168.36.110 netmask 255.255.255.255 broadcast 192.168.36.255 up
ifconfig eth0:1 down
cat FileName.txt | grep closed | awk '{print $2"/"$5}'
cat FileName.txt | grep closed | awk '{print $2" "$5}'
cat FileName.txt | grep -E "closed|filtered" # 多个匹配值
[root@openvpn nmap]# cat 2223Result.txt | more
例如:
FileName.txt
# Nmap 6.40 scan initiated Wed Sep 23 14:14:18 2020 as: nmap -p 22-23 -Pn -oG 2223Result.txt -iL 5Cisco.txt
Host: 10.32.96.5 () Status: Up
Host: 10.32.96.5 () Ports: 22/open/tcp//ssh///, 23/open/tcp//telnet///
Host: 10.34.32.5 () Status: Up
Host: 10.34.32.5 () Ports: 22/closed/tcp//ssh///, 23/open/tcp//telnet///
Host: 10.34.32.7 () Status: Up
Host: 10.34.32.7 () Ports: 22/closed/tcp//ssh///, 23/filtered/tcp//telnet///
Host: 10.45.192.5 () Status: Up
Host: 10.45.192.5 () Ports: 22/closed/tcp//ssh///, 23/open/tcp//telnet//
Host: 10.32.96.21 () Status: Up
Host: 10.32.96.21 () Ports: 22/open/tcp//ssh///, 23/open/tcp//telnet///
[root@openvpn nmap]# cat FileName.txt | grep closed | awk '{print $2"/"$5}'
10.34.32.5/22/closed/tcp//ssh///,
10.34.32.7/22/closed/tcp//ssh///,
10.45.192.5/22/closed/tcp//ssh///,
[root@openvpn nmap]# cat FileName.txt | grep closed | awk '{print $2" "$5}'
10.34.32.5 22/closed/tcp//ssh///,
10.34.32.7 22/closed/tcp//ssh///,
10.45.192.5 22/closed/tcp//ssh///,
[root@openvpn nmap]# cat FileName.txt | grep closed | awk '{print $2" "$5}' | awk -F'/' '{ print $1" "$2}'
10.34.32.5 22 closed
10.34.32.7 22 closed
10.45.192.5 22 closed
[root@openvpn nmap]# cat FileName.txt | grep closed | awk '{print $2" "$5}' | awk -F'/' '{ print $1""$2}'
10.34.32.5 22closed
10.34.32.7 22closed
10.45.192.5 22closed
[root@openvpn nmap]#
grep只输出匹配的内容
1、输出eth0的IP地址
ip -4 addr show "eth0" | grep -oP '(?<=inet\s)\d+(\.\d+){3}'
2、说明
-o 显示被模式匹配到的字符串。
-P 支持正则表达式
(https://deerchao.cn/tutorials/regex/regex.htm#lookaround)
(?=exp)也叫零宽度正预测先行断言,它断言自身出现的位置的后面能匹配表达式exp
(?<=exp)也叫零宽度正回顾后发断言,它断言自身出现的位置的前面能匹配表达式exp
[root@openvpn SiteCount]# cat SitesCount.sh
#!/bin/bash
# "NetworkIdentifier" date comes from "ip-layout20150907.xls"
#
cat NetworkIdentifier | while read LINE
do
{
IP1=`echo $LINE |cut -d "." -f1`
IP2=`echo $LINE |cut -d "." -f2`
IP3=`echo $LINE |cut -d "." -f3`
Router1=$IP1.$IP2.$IP3.1
Router2=$IP1.$IP2.$IP3.2
CoreSW=$IP1.$IP2.$IP3.5
if ping -c 1 -W 1 $Router1 &> /dev/null || ping -c 1 -W 1 $Router2 &> /dev/null; then
echo "$LINE" >> AliveSites.txt
# echo "$LINE is up." | tee >> IP-Addr.txt
else
echo "$LINE" >> UnreachableSites.txt
echo "$IP1.$IP2.$IP3.0" >> Prefix.txt
fi
if ping -c 1 -W 1 $CoreSW &> /dev/null; then
echo "$CoreSW" >> CoreSW.txt
fi
}
done
echo "Current Alive Sites Number: `cat AliveSites.txt |wc -l`"
echo -e "\t\t\t\t\t\t\t\t\t `date +'%Y/%m/%d %H:%M:%S'`"
[root@openvpn SiteCount]# grep -o "\S*txt" SitesCount.sh
[root@openvpn SiteCount]# grep -oh "\S*txt" SitesCount.sh
[root@openvpn SiteCount]# grep -oP "\S*txt" SitesCount.sh
AliveSites.txt
IP-Addr.txt
UnreachableSites.txt
Prefix.txt
CoreSW.txt
AliveSites.txt
[root@openvpn SiteCount]#
-o, --only-matching
Print only the matched (non-empty) parts of a matching line,
with each such part on a separate output line.
-h, --no-filename
Suppress the prefixing of file names on output. This is the default
when there is only one file (or only standard input) to search.
-P, --perl-regexp
Interpret PATTERN as a Perl regular expression. This is highly
experimental and grep -P may warn of unimplemented features.
-r, --recursive
Read all files under each directory, recursively,
following symbolic links only if they are on the command line.
This is equivalent to the -d recurse option.
-R, --dereference-recursive
Read all files under each directory, recursively.
Follow all symbolic links, unlike -r.
打包成tar.gz格式压缩包
# tar -zcvf renwolesshel.tar.gz /renwolesshel
解压tar.gz格式压缩包
# tar zxvf renwolesshel.tar.gz
# -z, --gzip, --gunzip --ungzip
cd /opt/unetlab ; tar -czvf /root/labs-backup.tgz labs
# 解压到指定目录-C
# tar xvf vmxvfp-20.2R2-S1.3.tgz -C /opt/unetlab/addons/qemu
打包成tar.bz2格式压缩包
# tar -jcvf renwolesshel.tar.bz2 /renwolesshel
解压tar.bz2格式的压缩包
# tar jxvf renwolesshel.tar.bz2
压缩成zip格式
# zip -q -r renwolesshel.zip renwolesshel/
解压zip格式的压缩包
# unzip renwolesshel.zip
查询当前目录总大小可以使用du -sh,其中s代表统计汇总的意思,即只输出一个总和大小;
du -h –max-depth=0 * # 只显示直接子目录文件及文件夹大小统计值
du -sh <目录名称> # 只想查看指定目录的总大小
du -sh # 查看当前目录大小
du -h --max-depth=1 # 查看当前目录下所有一级子目录文件夹大小
du -m --max-depth=1|sort -nr # 按照目录大小进行倒序排序(以M为单位显示)
# curl -A "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36" -s "https://ip138.com/iplookup.asp?ip=52.7.6.7&action=2" | iconv -f gb2312 -t utf-8 | grep "ip_result =" | awk -F "ASN归属地\":" '{print $2}' | awk -F, '{print $1}'
"美国 弗吉尼亚 阿什本 亚马逊云 数据中心"
#
curl http://name.oss-cn.aliyuncs.com
curl -l http://name.oss-cn-hangzhou.aliyuncs.com
curl -voa "http://name.oss-cn-hangzhou.aliyuncs.com"
root@WRT1900ACS-part1:~# curl name.oss-cn-hangzhou.aliyuncs.com
curl: (56) Recv failure: Connection reset by peer
root@WRT1900ACS-part1:~#
root@WRT1900ACS-part1:~# curl name.oss-cn-hangzhou.aliyuncs.com
<?xml version="1.0" encoding="UTF-8"?>
<Error>
<Code>AccessDenied</Code>
<Message>Anonymous user has no right to access this bucket.</Message>
<RequestId>5FE*********BA5</RequestId>
<HostId>name.oss-cn-hangzhou.aliyuncs.com</HostId>
</Error>
root@WRT1900ACS-part1:~#
[root@proxy1 ~]# curl -voa "http://name.oss-cn-hangzhou.aliyuncs.com"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to name.oss-cn-hangzhou.aliyuncs.com port 80 (#0)
* Trying 183.*.*.9...
* Connected to express-eurus.oss-cn-hangzhou.aliyuncs.com (183.*.*.9) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: name.oss-cn-hangzhou.aliyuncs.com
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Server: AliyunOSS
< Date: Wed, 23 Dec 2020 11:26:24 GMT
< Content-Type: application/xml
< Content-Length: 268
< Connection: keep-alive
< x-oss-request-id: 5FE************D6F
< x-oss-server-time: 0
<
{ [data not shown]
100 268 100 268 0 0 2413 0 --:--:-- --:--:-- --:--:-- 2436
* Connection #0 to host name.oss-cn-hangzhou.aliyuncs.com left intact
[root@proxy1 ~]#
[root@proxy1 ~]# curl -voa "https://name.oss-cn-hangzhou.aliyuncs.com"
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* About to connect() to name.oss-cn-hangzhou.aliyuncs.com port 443 (#0)
* Trying 124.*.*.3...
* Connected to name.oss-cn-hangzhou.aliyuncs.com (124.*.*.3) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0* NSS error -5961 (PR_CONNECT_RESET_ERROR)
* TCP connection reset by peer
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
* Closing connection 0
curl: (35) TCP connection reset by peer
[root@proxy1 ~]#
cd /etc/config/
sed -i "23i\ list server '/outlook.office365.com/10.1.1.1'" dhcp
sed -i "24i\ list server '/login.windows.net/10.1.1.1'" dhcp
/etc/init.d/dnsmasq restart
[root@vrgv WEB-INF]# sed -i '49i <!--' web.xml # 在第49行插入,原第49行变成50行
[root@vrgv WEB-INF]# sed -i '54i -->' web.xml
sed '/5/ a\ 456\ 123 ' ~/install.log # 在第5行后第6行插入
sed '/5/ i\ 456\ 123 ' ~/install.log # 在第5行插入
ssh -l Username -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null 192.168.*.5
ssh -l Username -o KexAlgorithms=+diffie-hellman-group1-sha1 -c aes256-cbc 10.*.*.253
/*
root@openvpn-16:~# ssh -l Username 10.*.*.253
Unable to negotiate with 10.*.*.253 port 22: no matching key exchange method found. Their offer: diffie-hellman-group1-sha1
root@openvpn-16:~# ssh -l Username -o KexAlgorithms=+diffie-hellman-group1-sha1 10.*.*.253
Unable to negotiate with 10.*.*.253 port 22: no matching cipher found. Their offer: aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
root@openvpn-16:~# ssh -l Username -o KexAlgorithms=+diffie-hellman-group1-sha1 -c aes256-cbc 10.*.*.253
RSA key fingerprint is SHA256:aLI0FC0k++iScWO8N/eK7nO0yb7WFE/QUIoLfVGB1/4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.*.*.253' (RSA) to the list of known hosts.
password:
C2960-48TC>en
Password:
C2960-48TC#
[root@openvpn ~]#
Last login: Sun Apr 18 14:29:59 2021 from 10.x.x.16
[root@openvpn ~]# cat ~/.ssh/config
Host *
ControlMaster auto
ControlPath ~/.ssh/master-%r@%h:%p
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentityFile ~/.ssh/id_rsa
Host 10.1.1.1
User root
Port 22
IdentityFile ~/.ssh/id_rsa
Host tianjin.5
HostName 10.1.1.5
User UserName
Port 22
IdentityFile ~/.ssh/id_rsa
Host bfr.5
HostName 10.1.0.5
User UserName
Port 22
IdentityFile ~/.ssh/id_rsa
Host shijiazhuang.23
HostName 10.1.1.23
User UserName
Port 22
IdentityFile ~/.ssh/aaa
Host 10.1.1.23
User UserName
Port 22
IdentityFile ~/.ssh/aaa
Host *buntu
HostName 10.x.x.209
User UserName
Port 22
Host 10.*.*.1 # 此处*为通配符
User root
Port 22
Host 10.*.*.2
User root
Port 22
Host 10.*.*.108
User root
Port 22
Host 10.*.*.131
User root
Port 22
Host 10.*.*.254
User root
Port 22
Host 10.*.*.*
User UserName
Port 22
/*
```bash
$ ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
# Cisco IOS使用-b 1024
# 将本机公钥复制到远端主机,实现本机免密登陆远端主机
# ssh-copy-id — use locally available keys to authorise logins on a remote machine
ssh-copy-id -i /root/.ssh/id_rsa.pub root@192.168.3.22
ssh-copy-id macOS@centos7
/*
$ ssh macOS@centos7
macOS@centos7's password:
Last login: Fri Feb 5 20:08:51 2021 from 10.x.x.15
[macOS@openvpn ~]$ exit
$ ssh-copy-id macOS@centos7
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/Users/ross/.ssh/id_ed25519.pub"
/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
macOS@centos7's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh 'macOS@centos7'"
and check to make sure that only the key(s) you wanted were added.
$ ssh macOS@centos7
Last login: Sun Feb 7 10:29:36 2021 from 10.x.x.15
[macOS@openvpn ~]$
----
http://www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html
六、authorized_keys文件
远程主机将用户的公钥,保存在登录后的用户主目录的$HOME/.ssh/authorized_keys文件中。公钥就是一段字符串,只要把它追加在authorized_keys文件的末尾就行了。
这里不使用上面的ssh-copy-id命令,改用下面的命令,解释公钥的保存过程:
$ ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
这条命令由多个语句组成,依次分解开来看:
(1)"$ ssh user@host",表示登录远程主机;
(2)单引号中的mkdir .ssh && cat >> .ssh/authorized_keys,表示登录后在远程shell上执行的命令:
(3)"$ mkdir -p .ssh"的作用是,如果用户主目录中的.ssh目录不存在,就创建一个;(4)'cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub的作用是,将本地的公钥文件~/.ssh/id_rsa.pub,重定向追加到远程文件authorized_keys的末尾。
写入authorized_keys文件后,公钥登录的设置就完成了。
*/
Linux注销已登录用户/Linux强制踢出已登录的用户
/*
查看在线用户 #w
注销用户 #pkill -kill -t tty
[root@openvpn ~]# w
20:02:06 up 50 days, 30 min, 5 users, load average: 0.00, 0.01, 0.05
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
root pts/0 10.xx.xx.153 Tue17 55:58 0.19s 0.19s -bash
root pts/1 10.xx.xx.153 19:36 6.00s 0.00s 0.00s w
macOS pts/2 10.xx.xx.153 Wed15 1:24m 0.20s 0.20s -bash
root pts/3 10.xx.xx.153 20:00 1:11 0.00s 0.00s -bash
macOS pts/4 10.xx.xx.153 19:55 6:42 0.00s 0.00s -bash
[root@openvpn ~]# pkill -kill -t pts/0
*/
```bash
Linux查看文件时间 | Linux修改ls显示的时间格式
https://blog.csdn.net/qq_26614295/article/details/78899978
/*
[root@openvpn tmp]# stat args01.sh
File: ‘args01.sh’
Size: 167 Blocks: 8 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 19671044 Links: 1
Access: (0755/-rwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2021-02-12 18:05:53.384294500 +0800
Modify: 2021-02-12 18:05:51.476262340 +0800
Change: 2021-02-12 18:08:06.949545584 +0800
Birth: -
[root@openvpn tmp]# ls -l --time-style '+%Y/%m/%d %H:%M:%S' args01.sh
-rwxr-xr-x 1 root root 167 2021/02/12 18:05:51 args01.sh
[root@openvpn tmp]#
修改配置到bash_profile:
[liul@test dataload]$ vi ~/.bash_profile
[liul@test dataload]$ source ~/.bash_profile
[liul@test dataload]$ cat ~/.bash_profile | grep TIME
export TIME_STYLE='+%Y/%m/%d %H:%M:%S'
[liul@test dataload]$ source ~/.bash_profile
*/
设置ls -l命令中显示的日期格式
/*
https://blog.csdn.net/qq_23954053/article/details/74025727
1、临时更改显示样式,当回话结束后恢复原来的样式
export TIME_STYLE='+%Y-%m-%d %H:%M:%S' # 直接在命令中执行即可
2、永久改变显示样式,更改后的效果会保存下来
修改/etc/profile文件,在文件内容末尾加入
export TIME_STYLE='+%Y-%m-%d %H:%M:%S'
执行如下命令,使你修改后的/etc/profile文件配置内容生效
source /etc/profile
*/