Linux Tips for Operator

2022-06-10T10:42:03+08:00

下面这些多是本人日常开发运维会用到的tips,希望也能对读者有所帮助,时不时更新

ssh 代理登录 #

137只能通过133当跳板机登录,则可以通过 -J (jump) 参数指定跳板机,

#1.1做为跳板机
ssh  -J  [email protected]:28996  [email protected] -v

#133做为跳板机
ssh -J [email protected] [email protected]

同样适用于rsync来同步文件

rsync -arvP -e ' ssh  -J  [email protected]:28996 ' [email protected]:/home/jialinwu/.config/alacritty/alacritty_macos.yml .

rsync -rvP -e 'ssh -J [email protected] ' --progress ./File [email protected]:/data/pending

date: 2021-01-02T10:42:03+08:00

netstat #

比如要看8001端口被哪个进程使用可以通过命令netstat -a -p |grep $pid

top #

top -p $pid

top -> x-> b -> <>

eE

ls /proc/$pid/fd/* |wc -l

让ssh走本地http代理 #

需要安装corkscrew这个工具

Host    jialinwu.com
Hostname        176.122.163.100
ProxyCommand /usr/local/bin/corkscrew 127.0.0.1 1087 %h %p
IdentityFile ~/.ssh/id_rsa
port 22
User    "root"

curl 测试websocket链接 #

curl --include \
     --no-buffer \
     --header "Connection: Upgrade" \
     --header "Upgrade: websocket" \
     --header "Host: example.com:80" \
     --header "Origin: http://example.com:80" \
     --header "Sec-WebSocket-Key: SGVsbG8sIHdvcmxkIQ==" \
     --header "Sec-WebSocket-Version: 13" \
     http://192.168.1.47:1443/ast

curl 测试链接耗时,DNS, connection establishment #

curl -w "@parameters.txt" -o /dev/null -s -L "http://192.168.1.47:6004/ast"

parameters.txt 文件内容如下:

time_namelookup: %{time_namelookup}\n
time_connect: %{time_connect}\n
time_appconnect: %{time_appconnect}\n
time_redirect: %{time_redirect}\n
time_pretransfer: %{time_pretransfer}\n
time_starttransfer: %{time_starttransfer}\n
----------\n
time_total: %{time_total}\n

2022-12-18