生命之中的最大错误在于:终日担心犯错误。— 爱尔伯特·哈伯德 (Elbert Hubbard 1856-1915),《笔记》
最近对postfix的使用又产生了点兴趣,特实验并整理一下相关的使用:
一 安装
yum install postfix
参考:postfix基本配置和设定DNS
二 配置默认发送域名
配置文件可以设定:
mydomain = mail.yourdomain.com
myhostname = yourdomain.com
如果不行,可以试试这样(笨人方法):
hostname yourdomain.com
service postfix restart
这样发出的邮件就是 xx@yourdomain.com
三 配置收邮件
inet_interfaces = all
四 希望收到的邮件提供给PHP处理
修改 aliases文件要执行 newaliases 才能生效
这样发给 aslibra@yourdomain.com 的邮件会交给 /tmp/m.php 处理
程序参考: PHP处理postfix的邮件内容
五 希望增加收邮件的域名
别的域名的邮件发到此服务器是会有出错提示的,不处理的,修改一下即可
mydestination = $myhostname, localhost.$mydomain, localhost, www.aslibra.com
这样 xx@www.aslibra.com 的邮件就可以处理了
六 希望做邮件转发
比如 xxxx@www.aslibra.com 全部都交给php处理,这个用处很大,可以用程序处理用户邮件交互
1 编辑 /etc/postfix/canonical 增加一行
@www.aslibra.com aslibra@yourdomain.com
2 postconf -e canonical_maps=hash:/etc/postfix/canonical
3 postmap /etc/postfix/canonical
这样邮件就都交给前面设定的用户了,继而交给php处理了
# 参考资料:
1 Postfix 邮件转发
一 安装
yum install postfix
参考:postfix基本配置和设定DNS
二 配置默认发送域名
配置文件可以设定:
mydomain = mail.yourdomain.com
myhostname = yourdomain.com
如果不行,可以试试这样(笨人方法):
hostname yourdomain.com
service postfix restart
这样发出的邮件就是 xx@yourdomain.com
三 配置收邮件
inet_interfaces = all
四 希望收到的邮件提供给PHP处理
cat /etc/aliases | grep aslibra
aslibra: "| php -q /tmp/m.php"
aslibra: "| php -q /tmp/m.php"
修改 aliases文件要执行 newaliases 才能生效
这样发给 aslibra@yourdomain.com 的邮件会交给 /tmp/m.php 处理
程序参考: PHP处理postfix的邮件内容
五 希望增加收邮件的域名
别的域名的邮件发到此服务器是会有出错提示的,不处理的,修改一下即可
mydestination = $myhostname, localhost.$mydomain, localhost, www.aslibra.com
这样 xx@www.aslibra.com 的邮件就可以处理了
六 希望做邮件转发
比如 xxxx@www.aslibra.com 全部都交给php处理,这个用处很大,可以用程序处理用户邮件交互
1 编辑 /etc/postfix/canonical 增加一行
@www.aslibra.com aslibra@yourdomain.com
2 postconf -e canonical_maps=hash:/etc/postfix/canonical
3 postmap /etc/postfix/canonical
这样邮件就都交给前面设定的用户了,继而交给php处理了
# 参考资料:
1 Postfix 邮件转发
假设我们在client.aslibra.com的机器要实现免输入密码登录到server.aslibra.com
那要做什么事情呢?
1 client生成密钥
2 client把公钥上传到server
3 server把公钥加入到自己的authorized_keys文件即可
修改@0508:
谢谢profans的提示,2和3一步就可以完成啦!实验过,正常。
MAC: ssh-copy-id in Mac OS X
For some reason Macs don’t have this useful script so this will add it.
那要做什么事情呢?
1 client生成密钥
2 client把公钥上传到server
3 server把公钥加入到自己的authorized_keys文件即可
修改@0508:
谢谢profans的提示,2和3一步就可以完成啦!实验过,正常。
#生成密钥后
ssh-copy-id -i .ssh/id_rsa.pub server.aslibra.com
ssh-copy-id -i .ssh/id_rsa.pub server.aslibra.com
MAC: ssh-copy-id in Mac OS X
For some reason Macs don’t have this useful script so this will add it.
sudo curl "http://phildawson.co.uk/ssh-copy-id" -o /usr/bin/ssh-copy-id
sudo chmod +x /usr/bin/ssh-copy-id
sudo chmod +x /usr/bin/ssh-copy-id
ssh账号代理上网是很常见的,尤其是翻越障碍物的时候很实用。
ssh账号是可以登录linux系统的,如果只是上网用,那就需要最小化权限,有两个方式:
1 /bin/false
2 自定义脚本
输入字符后会退出,不会产生系统操作
ssh账号是可以登录linux系统的,如果只是上网用,那就需要最小化权限,有两个方式:
1 /bin/false
useradd -s /bin/false yourUser
#登录时使用这样的:
ssh -D 7070 -N yourUser@hostname
#登录时使用这样的:
ssh -D 7070 -N yourUser@hostname
2 自定义脚本
cat /bin/tunnel.sh
#!/bin/sh
echo "##########"
echo " welcome !"
echo "##########"
read x
exit
useradd -s /bin/tunnel.sh yourUser
ssh -D 7070 yourUser@hostname
#!/bin/sh
echo "##########"
echo " welcome !"
echo "##########"
read x
exit
useradd -s /bin/tunnel.sh yourUser
ssh -D 7070 yourUser@hostname
输入字符后会退出,不会产生系统操作
在这里仅保留了计划任务,网络,ssh以及日志
适用redhat和centos
chkconfig --list | grep 3:on | \
grep -v "crond\|network\|sshd\|syslog" | \
awk '{print "chkconfig " $1 " off"}' | sh
grep -v "crond\|network\|sshd\|syslog" | \
awk '{print "chkconfig " $1 " off"}' | sh
适用redhat和centos
Linux内核漏洞最近几乎是一月一爆,在8月15号才爆了一个几乎通杀所有版本所有内核所有架构的内核漏洞;通杀内核2.6 < 2.6.19的所有32位Linux。
redhat已经发布补丁 RHSA-2009:1223 – Security Advisory
rhel4打到2.6.9-89.0.9内核就没事了,RHEL5没时间验证,基本上yum升级一下可以解决问题。
##########################
iptables的output链对UDP包做了限制会导致无法成功提权
跟一下这个程序:
redhat已经发布补丁 RHSA-2009:1223 – Security Advisory
rhel4打到2.6.9-89.0.9内核就没事了,RHEL5没时间验证,基本上yum升级一下可以解决问题。
##########################
iptables的output链对UDP包做了限制会导致无法成功提权
跟一下这个程序:
脚本示例:
使用shell批量删除10天内没访问过的文件
find命令有一个参数可以避免特殊字符对后面执行的命令产生影响
命令变成这样:
一般来说不会有什么问题,但如果每个文件路径都特别深,那么会导致参数很多,命令行很长。
比如会看到如下提示:
那可以让xargs一次处理一条试试:
-l1是一次处理一个
-t是处理之前打印出命令,适合调试或者欣赏观看用
find . -type f -atime +10 | xargs rm -f
使用shell批量删除10天内没访问过的文件
find命令有一个参数可以避免特殊字符对后面执行的命令产生影响
-print0
True; print the full file name on the standard output, followed by a null character (instead of the new-
line character that ‘-print’ uses). This allows file names that contain newlines or other types of
white space to be correctly interpreted by programs that process the find output. This option corre-
sponds to the ‘-0’ option of xargs.
True; print the full file name on the standard output, followed by a null character (instead of the new-
line character that ‘-print’ uses). This allows file names that contain newlines or other types of
white space to be correctly interpreted by programs that process the find output. This option corre-
sponds to the ‘-0’ option of xargs.
命令变成这样:
find . -type f -atime +10 -print0 | xargs -0 rm -f
一般来说不会有什么问题,但如果每个文件路径都特别深,那么会导致参数很多,命令行很长。
比如会看到如下提示:
xargs: argument line too long
那可以让xargs一次处理一条试试:
find . -type f -atime +10 -print0 | xargs -0 -l1 -t rm -f
-l1是一次处理一个
-t是处理之前打印出命令,适合调试或者欣赏观看用
题记:如果您刚看到此文,相信一定不想错过怎么将Ubuntu安装进U盘、LAMP网站开发环境搭建这两篇文章。由了以上两篇文章,即便是从零起步,也可以用Ubuntu做些什么了。在这篇文章里,我将列举一些,Ubuntu平台必备工具软件。






