Linux / Windows / 学习笔记 / 常用工具 / 私密文章

常用SSH命令

迷失小白菜 · 11月8日 · 2019年 · 565次已读

个人常用宏脚本

# info

# 脚本测试
curl -Lso- https://raw.githubusercontent.com/oooldking/script/master/superbench.sh | bash
# 看开放的端口
netstat -lntup
# 看有连接的端口
netstat -ant
# 看进程
ps aux
htop
# 搜索文件 位置 and 条件
find / -name *.sh
# 搜索目录内的指定文本内容 grep -irn "条件" 位置
grep -irn "rsa" /root/.ssh
grep -irn PasswordAuthentication /etc/ssh/sshd_config
# DNS

# 国外
rm -f /etc/resolv.conf;echo -e "nameserver 8.8.8.8\nnameserver 8.8.4.4\nnameserver 208.67.222.222\nnameserver 208.67.220.220\noptions timeout:1 rotate" >> /etc/resolv.conf;
# 国内
rm -f /etc/resolv.conf;echo -e "nameserver 114.114.114.114\nnameserver 119.29.29.29\nnameserver 223.5.5.5\nnameserver 223.6.6.6\noptions timeout:1 rotate" >> /etc/resolv.conf;
# 查看本机外网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服务
service sshd restart;
/etc/init.d/ssh restart;
# 查看当前ssh端口
grep ^Port /etc/ssh/sshd_config | awk '{print $2}'
# 场景列表
screen -list
# 安装场景
yum -y install screen
# 恢复场景
screen -r asf
# 创建场景
screen -S asf
# bitwarden
docker pull bitwardenrs/server:latest
docker kill bitwarden
docker rm bitwarden
docker run -d --name bitwarden -v /home/bwdata/:/data/ -p 3000:80 bitwardenrs/server:latest
#docker logs --tail 30 -f bitwarden
docker logs bitwarden
# -----------
docker image ls
docker image rm 多余的镜像
# 锐速

# 常规安装 https://github.com/wxlost/lotServer
bash <(wget --no-check-certificate -qO- https://github.com/wxlost/lotServer/raw/master/Install.sh) install
# 指定内核安装 查看内核列表:http://download.appexnetworks.com.cn/ls.do?m=availables
uname -a
bash <(wget --no-check-certificate -qO- https://github.com/wxlost/lotServer/raw/master/Install.sh) install 内核代码
# 状态
bash /appex/bin/lotServer.sh status
# 卸载
bash <(wget --no-check-certificate -qO- https://github.com/MoeClub/lotServer/raw/master/Install.sh) uninstall
# 授权码获取
# /appex/etc/apx.lic
https://118868.xyz/keygen.php?mac=00:00:00:00:00:00
#BBR

# 安装
wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
#wget --no-check-certificate https://github.com/teddysun/across/raw/master/bbr.sh && chmod +x bbr.sh && ./bbr.sh

# 查看效果
lsmod | grep bbr
# 高版本 Centos 7.7 开启bbr --注意.可能会导致无法开机

# 下载更换内核
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
yum --enablerepo=elrepo-kernel install kernel-ml -y

# 查看内核是否安装成功
rpm -qa | grep kernel

# 查看内核启动代码
cat /etc/grub2-efi.cfg |grep menuentry

# 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