海运的博客

Centos/Debian重置root密码方法

发布时间:January 5, 2013 // 分类:Linux基础 // No Comments

Centos下进入单用户模式修改root密码,添加GRUB引导参数:

single

Debian直接引导进入Bash环境,添加GRUB引导参数:

init=/bin/bash

进入Bash后挂载系统为读写并修改root密码:

mount -no remount,rw /
passwd

一次root不能登录及ssh不能启动解决

发布时间:December 27, 2012 // 分类:Linux基础 // No Comments

一客户联系说VPS在让其朋友安装SquidSSH不能登录了,分析OpenSSH未正常启动,然后通过VNC终端使用用户提供的密码也不能登录,当时以为密码有误,不得已进入单用户模式重置密码,然后再次尝试登录依旧,不得已再次进入单用户模式查找原因,验证错误日记如下:

Dec 27 14:36:30 ONOVPS login: pam_securetty(login:auth): /etc/securetty is either world writable or not a normal file
Dec 27 14:36:35 ONOVPS login: FAILED LOGIN 1 FROM (null) FOR root, Authentication failure

可见是/etc/securetty文件或权限有问题,此文件可限制root登录的终端,正常权限600,查看权限:

ls -al /etc/securetty 
-rwxrwxrwx 1 root root 127 Mar  3  2011 /etc/securetty

重置权限正常登入VPS,启动SSH依旧提示权限有误,查看/etc/目录竟然都整成777权限了,那个郁闷呀。。。。

Centos软件包管理工具yum和rpm常用命令

发布时间:August 28, 2012 // 分类:Linux基础 // No Comments

CentOS包管理rpm常用命令,查询未安装软件时加参数p:

#https://www.haiyun.me
rpm -qa #列出系统当前安装的软件
rmm -qa pkg #查询系统是否已安装特定软件
rpm -qf /path/file #查询特定文件属于哪个软件
rpm -ql pkg #列出软件所包含的文件
rpm -qi pkg #查询已安装软件的详细信息
rpm -qR pkg #查询已安装软件的依赖关系
rpm -qd pkg #查询已安装软件的文档目录
rpm -ivh pkg #安装软件
rpm -Uvh pkg #更新软件
rpm -e pkg #删除软件

yum常用命令:

yum install pkg #安装软件
yum remove pkg #删除软件
yum check-update #检查更新
yum update #更新
yum clean all #清除所有缓存
yum search pkg #搜索软件
yum deplist pkg #查看依赖关系

Centos5.7不编译内核安装Iptables Layer7模块

发布时间:July 29, 2012 // 分类:Iptables,Linux基础 // No Comments

Centos查看当前内核、Iptables版本并下载相应源码:

#https://www.haiyun.me
uname -r
2.6.18-274.el5
cd /usr/src/kernels/
wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-2.6.18.tar.gz
iptables -V
iptables v1.3.5
wget http://ftp.netfilter.org/pub/iptables/iptables-1.3.5.tar.bz2

或下载Centos官方内核源码:

useradd test
su -l test
mkdir -p ~/rpmbuild/{BUILD,BUILDROOT,RPMS,SOURCES,SPECS,SRPMS}
echo '%_topdir %(echo $HOME)/rpmbuild' > ~/.rpmmacros
yum install rpm-build redhat-rpm-config unifdef
rpm -i http://vault.centos.org/5.7/os/SRPMS/kernel-2.6.18-274.el5.src.rpm
cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec
cd ~/rpmbuild/BUILD/kernel*/linux*/ #源码所在目录

下载Layer7模块和规则文件:

wget http://sourceforge.net/projects/l7-filter/files/l7-filter%20kernel%20version/2.18/netfilter-layer7-v2.18.tar.gz
wget http://sourceforge.net/projects/l7-filter/files/Protocol%20definitions/2009-05-28/l7-protocols-2009-05-28.tar.gz

给内核打上Layer7补丁并编译模块:

tar zxvf linux-2.6.18.tar.gz 
tar zxvf netfilter-layer7-v2.18.tar.gz
cd linux-2.6.18
patch -p1 < ../netfilter-layer7-v2.18/for_older_kernels/kernel-2.6.18-2.6.19-layer7-2.9.patch
#查看READ文件根据内核版本选择相应的补丁
yum install -y ncurses-devel 
#安装ncurses库,编译内核需要
make oldconfig
#备份配置文件
make menuconfig
#进入内核编译选项

在以下菜单处理选择将layer7编译为模块:

Networking——Networking options--->Network packet filtering (replaces ipchains)--->Layer 7 match support (EXPERIMENTAL) 

编译内核模块:

#https://www.haiyun.me
make prepare
make modules_prepare
#创建外部模块所需文件,后续可直接编译指定模块
make M=net/ipv4/netfilter/
#仅编译防火墙相关模块

复制编译的layer7.ko模块至系统:

strip --strip-debug net/ipv4/netfilter/ipt_layer7.ko
cp net/ipv4/netfilter/ipt_layer7.ko /lib/modules/2.6.18-274.el5/kernel/net/ipv4/netfilter/
chmod 744 /lib/modules/2.6.18-274.el5/kernel/net/ipv4/netfilter/ipt_layer7.ko 
depmod -a

编译安装Iptables layer7模块:

tar jxvf iptables-1.3.5.tar.bz2 
cd iptables-1.3.5
patch -p1 < ../netfilter-layer7-v2.18/iptables-1.3-for-kernel-pre2.6.20-layer7-2.18.patch 
#给iptables打上layer7补丁,阅读README根据内核及Iptables版本选择相应的补丁
chmod +x extensions/.layer7-test 
make KERNEL_DIR=/usr/src/kernels/linux-2.6.18
make install KERNEL_DIR=/usr/src/kernels/linux-2.6.18

安装Layer7示例脚本:

tar -zxvf l7-protocols-2009-05-28.tar.gz
cd l7-protocols-2009-05-28
make install

应用示例:

modprobe ipt_layer7
/usr/local/sbin/iptables -A FORWARD -m layer7 --l7proto qq -j DROP 

Centos安装X window配置ssh X转发

发布时间:July 14, 2012 // 分类:Linux基础 // No Comments

先安装X Window环境:

#https://www.haiyun.me
yum groupinstall "X Window System"

配置SSH开启X转发:

cat /etc/ssh/sshd_config
X11Forwarding yes

SSH客户端开启X转发,Xshell设置如下:
xshell开启X转发.png
安装X-Server for Windows,推荐免费开源Xming

分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...