Logo迷失博客
返回文章列表
常用工具阅读时长:2 分钟

常用SSH命令

发布时间:2019年11月08日 08:00最后修改:2026年09月15日 06:15

Linux 常用运维命令速查手册,包含综合性能测速、DNS 设置、SSH 密码登录控制与 BBR 加速配置。

个人常用宏脚本

# 综合系统性能测试 (YABS)
curl -sL yabs.sh | bash

# 查看监听中的端口
netstat -lntup || ss -tulpn
# 查看已建立的连接
netstat -ant || ss -t
# 查看系统运行进程
ps aux
htop
# 按文件名搜索
find / -name "*.sh"
# 搜索配置文件中指定参数
grep -irn "PasswordAuthentication" /etc/ssh/sshd_config
# DNS

# 国外
cat > /etc/resolv.conf<<-EOF
nameserver 8.8.8.8
nameserver 1.1.1.1
options timeout:1 rotate
EOF

# 国内
cat > /etc/resolv.conf<<-EOF
nameserver 223.5.5.5
nameserver 114.114.114.114
options timeout:1 rotate
EOF

# 查看本机外网IP
curl myip.ipip.net
# 查看指定端口占用
netstat -tunlp grep 22
# Centos7 
yum -y install net-tools git wget
# 升级软件
yum --exclude=kernel* update
# 升级软件+内核
yum -y update
# SSH

# 开启密码登录
sed -i 's/^.*PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config;
# 禁用密码登录
if [ -z "grep ^PasswordAuthentication /etc/ssh/sshd_config" ]; then
sed -i "s@^#PasswordAuthentication.*@&\nPasswordAuthentication no@" /etc/ssh/sshd_config
else
sed -i "s@^PasswordAuthentication.*@PasswordAuthentication no@" /etc/ssh/sshd_config
fi
# 重启 sshd 服务
systemctl restart sshd
# 查看当前 ssh 端口
grep ^Port /etc/ssh/sshd_config | awk '{print $2}'
# screen 会话管理
screen -list
# 恢复会话
screen -r asf
# 创建会话
screen -S asf
# Vaultwarden 容器管理
docker pull vaultwarden/server:latest
docker stop vaultwarden && docker rm vaultwarden
docker run -d --name vaultwarden -v /home/bwdata/:/data/ -p 3000:80 vaultwarden/server:latest
docker logs -f vaultwarden
# Linux-NetSpeed
bash <(curl -fsL mcnb.top/tcp.sh)

# debian 8+ 开启bbr
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

# 观察BBR是否开启成功,执行以下代码:
sysctl net.ipv4.tcp_available_congestion_control && sysctl net.ipv4.tcp_congestion_control && lsmod  grep bbr

# 反馈结果都有bbr, 则证明你的内核已开启bbr

推荐阅读