重置opensolaris的root密码

新建一个用户,并用passwd给它设置密码,密码为空;
pfexec useradd test
pfexec passwd test
pfexec cat /etc/shadow | grep test
然后将第二列的内容copy到root的相应位置;(/etc/shadow是readonly的,所以wq是不行的,试试x!吧)
ok,使用su试一试,是不是密码为空了;

如果root还是不能登陆,试一试rolemod -K type=normal root

具体原因可参见:
http://wikis.sun.com/display/OpenSolarisInfo/Changing+root+User+Behavior

如果没有权限的话,那只要从CDROM启动。将rpool mount到本地,然后在修改/etc/shadow文件,就好了

具体的可参见: http://www.deadnode.org/articles/2010/04/08/reset-opensolaris-root-
password/

注意其中的 zfs set mountpoint=/export/tmp rpool/ ROOT /opensolaris是 重点哟!

如果还是觉得重置root密码很麻烦,那么使用pfexec bash, your done,你是root了。

在opensoalris下net-snmp使用的加密库

如果你在netsnmp的官网上的说明的话,你会以为他是用的是openssl,其实不是的,我刚开始也以为是使用的openssl,但是在多次尝试未果的情况下,我使用ldd才知道它使用的是libpkcs11.具体见下面的分析:

test@test:~# ldd /usr/sbin/snmpd
libc.so.1 => /lib/libc.so.1
libm.so.2 => /lib/libm.so.2
test@test:~# ldd /usr/sfw/sbin/amd64/snmpd
libnetsnmpagent.so.5 => /usr/lib/amd64/libnetsnmpagent.so.5
libnetsnmpmibs.so.5 => /usr/lib/amd64/libnetsnmpmibs.so.5
libnetsnmphelpers.so.5 => /usr/lib/amd64/libnetsnmphelpers.so.5
libnetsnmp.so.5 => /usr/lib/amd64/libnetsnmp.so.5
libkvm.so.1 => /usr/lib/amd64/libkvm.so.1
libz.so.1 => /usr/lib/amd64/libz.so.1
libpkcs11.so.1 => /usr/lib/amd64/libpkcs11.so.1
libkstat.so.1 => /usr/lib/amd64/libkstat.so.1
libelf.so.1 => /usr/lib/amd64/libelf.so.1
libm.so.2 => /usr/lib/amd64/libm.so.2
libdl.so.1 => /usr/lib/amd64/libdl.so.1
libnsl.so.1 => /usr/lib/amd64/libnsl.so.1
libsocket.so.1 => /usr/lib/amd64/libsocket.so.1
libadm.so.1 => /usr/lib/amd64/libadm.so.1
libc.so.1 => /usr/lib/amd64/libc.so.1
libcryptoutil.so.1 => /lib/64/libcryptoutil.so.1
libmp.so.2 => /lib/64/libmp.so.2
libmd.so.1 => /lib/64/libmd.so.1
libscf.so.1 => /lib/64/libscf.so.1
libuutil.so.1 => /lib/64/libuutil.so.1
libgen.so.1 => /lib/64/libgen.so.1
可以看到它根本没有使用到libcrypto.so,opensolaris对它进行重写。

refs:

http://blogs.sun.com/DanX/entry/where_s_the_crypto_libraries

在opensoalris下设置snmp v3用户

1.snmpd的版本
snmpd -v
NET-SNMP version: 5.0.9

2.对snmpd进行v3设置
具体步骤是:
2.1.查看snmpd支持的加密类型
snmpd -H 2>&1 | grep defPrivType
2.2.创建v3用户
pfexec rm -f /var/sma_snmp/snmpd.conf
pfexec net-snmp-config –create-snmpv3-user
2.3.在/etc/sma/snmp/snmpd.conf中追加下面三行,同时删除rwuser test
rwuser test noauth
rwuser test auth
rwuser test priv
2.4.重启snmpd,并运行以下命令测试:
pfexec svcadm disable /application/management/sma
pfexec svcadm enable /application/management/sma
pfexec cat /var/log/snmpd.log
snmpgetnext -v 3 -u test -l noAuthNoPriv localhost system
snmpgetnext -v 3 -u test -a MD5 -A testtest -l authNoPriv localhost system
snmpgetnext -v 3 -u test -a MD5 -A testtest -x DES -X testtest -l authPriv
localhost system
(最后一条显示:
Encryption support not enabled.
snmpgetnext: USM encryption error)
从提示来看,是该版本的snmpgetnext 不支持DES加密,所以可以使用支持snmp v3的client试一试,应该是可以的,我使用的是snmpB

备注:

SNMPv3:
USM:User-based Security Module for SNMPv3
VACM:View-based Access Control Model for SNMPv3
net-snmp-config –create-snmpv3-user [-ro] [-a authpass] [-x privpass] [-X
DES|AES] [-A MD5|SHA] [username]

杂项--20100514

windows:
turn on/off windows firewall with command:
netsh firewall set opmode enable
netsh firewall set opmode disable
递归copy目录:
xcopy
xcopy /e . e:/test

linux:
递归copy目录:
cp -r src dest
一次创建多级目录:
mkdir -p test/test/test

opensolaris:
在下查看包安装文件的路径:

pkg contents SUNWzfs 或者
pkg contents -t dir,file,link,hardlink -o
action.name,mode,pkg.size,path,target SUNWzfs
scp:
http://blogs.sun.com/janp/entry/how_the_scp_protocol_works
shutdown now:
pfexec uadmin 2 6

write mib and let it run

1.write mib
尽管这里没有具体写,但是写一个mib文件是很费力的事情。
将自己的mib文件放到: /etc/sma/snmp/mibs
(refs:
http://www.net-snmp.org/wiki/index.php/TUT:Using_and_loading_MIBS)
让snmpd加载你写的mib文件:
/etc/sma/snmp/snmp.conf:
追加一行: mibs +NET-SNMP-TUTORIAL-MIB
或者:
export MIBS=+NET-SNMP-TUTORIAL-MIB
svcadm restart svc:/application/management/sma:default
test your mib with snmptranslate:
根据名字得到OID:
snmptranslate -m +NET-SNMP-TUTORIAL-MIB -IR -On nstAgentPluginObject
或者:
snmptranslate -On NET-SNMP-TUTORIAL-MIB::nstAgentPluginObject
(.1.3.6.1.4.1.8072.2.4.1.1.3:numeric OID
NET-SNMP-TUTORIAL-MIB::nstAgentPluginObject:textual MIB name)
根据OID得到名字:
snmptranslate .1.3.6.1.4.1.8072.2.4.1.1.3
根据部分名字查找;
snmptranslate -IR nstAgentPluginObject
遍历mib树:
snmptranslate -Tp -IR system
显示详细:
snmptranslate -On -Td -IR sysUpTime
(refs:
http://net-snmp.sourceforge.net/wiki/index.php/TUT:snmptranslate)

2.write c
use mib2c to generate c code template:
pfexec mib2c -c /etc/sma/snmp/mib2c.int_watch.conf nstAgentPluginObject
write the implement nstAgentPluginObject.c
3.compile source
先要确认现在使用的snmpd是否支持dlmod,如果不支持的话,就要从source自己编译了,确认方法是snmpd
-H,然后查看输出是否有dlmod关键字,有的话,就是支持;
(注意系统中正在使用的snmpd版本是否和自己下载的source版本一致,如果相差很多的话,请下载相差最小的source,然后再运行下面的命令,否则的话会出现动态链接库被加载,但是实际上没有生效的情况)
./configure –enable-shared –with-mib-modules=”ucd_snmp”
cc -m64 -I yourSNMPSourcePath/net-snmp-5.0.11.2/include net-snmp-config --cflags -fPIC -shared -g -O0 -o nstAgentPluginObject.so
nstAgentPluginObject.c net-snmp-config --libs
modify snmpd.conf file:
dlmod nstAgentPluginObject yourDemoPath/nstAgentPluginObject.so
pfexec svcadm disable svc:/application/management/sma:default
pfexec svcadm enable svc:/application/management/sma:default
cat /var/log/snmpd.log
pfexec snmptable -v2c -c public localhost UCD-DLMOD-MIB::dlmodTable
pfexec snmpget -v2c -c public localhost NET-SNMP-TUTORIAL-
MIB::nstAgentPluginObject.0
pfexec snmpset -v2c -c private localhost NET-SNMP-TUTORIAL-
MIB::nstAgentPluginObject.0 = 5
pfexec snmpget -v2c -c public localhost NET-SNMP-TUTORIAL-
MIB::nstAgentPluginObject.0

参见我写的另外一篇文章:

http://blog.csdn.net/lantianjialiang/archive/2010/04/22/5515152.aspx

snmp相关组件的介绍

An SNMP-managed network consists of three key components:

  • Managed device = Slave device
  • Agent = software which runs on Slave device
  • Network management system (NMS) = software which runs on Master

A managed device is a network node that implements an SNMP interface that
allows unidirectional (read-only) or bidirectional access to node-specific
information. Managed devices exchange node-specific information with the NMSs.
Sometimes called network elements, the managed devices can be any type of
device, including, but not limited to, routers, access servers, switches,
bridges, hubs, IP telephones, IP video cameras, computer hosts, and printers.

An agent is a network-management software module that resides on a managed
device. An agent has local knowledge of management information and translates
that information to or from an SNMP specific form.

A network management system (NMS) executes applications that monitor and
control managed devices. NMSs provide the bulk of the processing and memory
resources required for network management. One or more NMSs may exist on any
managed network.

Community-Based Simple Network Management Protocol version 2, or SNMPv2c, is
defined in RFC 1901–RFC 1908.
RFC 2576 defines two possible SNMPv1/v2c coexistence strategies:
proxy agents
bilingual network-management systems.

如何增加vmware虚拟磁盘的容量

如果虚拟机是windows的话,推荐使用vmware converter;

如果不是的话,只能按下面的步骤来:
1. change disk size to your want:
vmware-vdiskmanager.exe -x 12Gb “YOUR_DISK.vmdk”

(vmware-vdiskmanager.exe只有在安装了workstation才有,如果你使用的workstatiopn
7的话,那恭喜你,你不需要命令行,可以直接在GUI上进行resize了)

2.let the os known you change:

use gparted to resize system partition to your size.
download gparted;
load gparted iso from vmware;
set system boot from cdrom(gparted not recognize zfs filesystem, so if your
want increase partition of opensolaris,
reinstall os);
resize system partition;
reboot;

refs:

http://beerpla.net/2007/08/10/how-to-resizegrow-vmware-linux-disks-and-
partitions/