11 月 272012
 

linux 断开某个用户的终端连接
断开某个用户的连接
who 查看用户连接

断开远程用户
fuser -k /dev/pts/x

x为who下看到的这个用户的pts序号

断开本地用户

fuser -k /dev/ttyx

x为who查看到的tty序号

11 月 272012
 

使用pwgen批量生成随机密码

安装

[root@oracle pwgen-2.06]# ./configure --prefix=/usr/local/pwgen
[root@oracle pwgen-2.06]# make
[root@oracle pwgen-2.06]# make install
mkdir -p /usr/local/pwgen/bin /usr/local/pwgen/man/man1
/usr/bin/install -c pwgen /usr/local/pwgen/bin/pwgen
/usr/bin/install -c -m 644 ./pwgen.1 /usr/local/pwgen/man/man1/pwgen.1
[root@oracle pwgen-2.06]#

查看帮助

[root@oracle bin]# ./pwgen --help
Usage: pwgen [ OPTIONS ] [ pw_length ] [ num_pw ]
Options supported by pwgen:
 -c or --capitalize
 Include at least one capital letter in the password
 -A or --no-capitalize
 Don't include capital letters in the password
 -n or --numerals
 Include at least one number in the password
 -0 or --no-numerals
 Don't include numbers in the password
 -y or --symbols
 Include at least one special symbol in the password
 -s or --secure
 Generate completely random passwords
 -B or --ambiguous
 Don't include ambiguous characters in the password
 -h or --help
 Print a help message
 -H or --sha1=path/to/file[#seed]
 Use sha1 hash of given file as a (not so) random generator
 -C
 Print the generated passwords in columns
 -1
 Don't print the generated passwords in columns
 -v or --no-vowels
 Do not use any vowels so as to avoid accidental nasty words

生成4组12位长度密码

[root@oracle bin]# ./pwgen 12 4
aik3ieC8oNee Chee6ririsi5 noiPo6aiquoo AeShaeriequ9

生成含有符号的4组12位长度密码

[root@oracle bin]# ./pwgen -y 12 4
uu!qu2Oobii4 kohM/ai6eith miReipi;th4e chu5ooj~ooNg

生成完全随机且含有符号的4组12位长度密码

[root@oracle bin]# ./pwgen -sy 12 4
g=~6J]!$}4Ws GK&0YCvj(pq~ AV`Q[Y|3wdwi ;0KUJ:f8bCCT

相关下载:
(1) pwgen 2.06

11 月 272012
 

Tomcat访问日志配置

#vi /usr/local/tomcat/conf/server.xml
<Valve className="org.apache.catalina.valves.FastCommonAccessLogValve"
directory="logs"  prefix="app01_access_log." suffix=".txt"
pattern="combined" resolveHosts="false"/>

日志文件目录

directory="logs"

日志文件前缀

prefix="app01_access_log."

日志文件后缀

suffix=".txt"

模式

common(默认)

192.168.11.70 - - [26/Nov/2012:17:12:35 +0800] "GET / HTTP/1.1" 200 8579
192.168.11.70 - - [26/Nov/2012:17:12:35 +0800] "GET /tomcat.gif HTTP/1.1" 200 1934
192.168.11.70 - - [26/Nov/2012:17:12:35 +0800] 
"GET /tomcat-power.gif HTTP/1.1" 200 2324
192.168.11.70 - - [26/Nov/2012:17:12:35 +0800] 
"GET /asf-logo-wide.gif HTTP/1.1" 200 5866

combined

192.168.11.70 - - [27/Nov/2012:13:27:37 +0800] "GET / HTTP/1.1" 200 8579 "-" 
"Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0"
192.168.11.70 - - [27/Nov/2012:13:27:37 +0800] "GET /tomcat.gif HTTP/1.1" 304 - 
"http://192.168.11.150:8080/" "Mozilla/5.0 (Windows NT 6.1; rv:16.0) 
Gecko/20100101 Firefox/16.0"
192.168.11.70 - - [27/Nov/2012:13:27:37 +0800] "GET /asf-logo-wide.gif HTTP/1.1" 
304 - "http://192.168.11.150:8080/" "Mozilla/5.0 (Windows NT 6.1; rv:16.0) 
Gecko/20100101 Firefox/16.0"
192.168.11.70 - - [27/Nov/2012:13:27:37 +0800] "GET /tomcat-power.gif HTTP/1.1" 
304 - "http://192.168.11.150:8080/" "Mozilla/5.0 (Windows NT 6.1; rv:16.0) 
Gecko/20100101 Firefox/16.0"
192.168.11.70 - - [27/Nov/2012:13:27:37 +0800] "GET /favicon.ico HTTP/1.1" 304 - 
"-" "Mozilla/5.0 (Windows NT 6.1; rv:16.0) Gecko/20100101 Firefox/16.0"

解析主机名

resolveHosts="false"

日志文件日期格式(可选参数)

fileDateFormat="yyyy-MM-dd.HH"

按月生成日志文件

fileDateFormat="yyyy-MM"
11 月 272012
 

如果丢失 admin 密码,则可以使用下列步骤将安全设备重置到其缺省设置。配置 将失去,但是对设备的访问将恢复。要执行此操作,需要连接控制台。

注意: 在缺省情况下,会启用设备恢复功能。可通过输入 unset admin device-reset 命 令禁用它。同样,如果安全设备处于 FIPS 模式,恢复特征被自动禁用。

1. 在登录提示下,输入设备的序列号。

2. 在密码提示下,再次输入序列号。

出现以下消息:

!!!! Lost Password Reset !!!!You have initiated a command to reset the device to 
factory defaults, clearing all current configuration, keys and settings.Would 
you like to continue? y/n

3. 按 y 键。

出现以下消息:

!! Reconfirm Lost Password Reset !!If you continue, the entire configuration of 
the device will be erased.In addition, a permanent counter will be incremented 
to signify that this device has been reset.This is your last chance to cancel 
this command.If you proceed, the device will return to factory default 
configuration, which is: System IP: 192.168.1.1; username: netscreen; 
password: netscreen.Would you like to continue? y/n

4. 按 y 键,重置设备。现在可以用 netscreen 作为缺省用户名和密码进行登录。