Wednesday, September 23, 2009

VI macro for showing line numbers.

First, create a file named .exrc in your home directory or edit your current one. This is the configuration file that vi reads when it is started. Put the following two lines into this file:

    :map #1 :set number^M
    :map #2 :set nonumber^M

A very important note: create the ^M characters in this file by typing the key sequence [CTRL-V][CTRL-M]

Now, save this file and re-start vi.Now be able to display line numbers simply hit the [F1] function key, and clear line numbers by hitting the [F2] key. If you like these macros, you can create your own by following these two examples.


Friday, September 18, 2009

Patching Solaris 10 with PCA "Patch Check Advanced"

PCA  is a free tool that can be used to patch solaris systems. One of the really cool thing about this tool is that it resolves the dependencies between patches.

You can grab PCA from here.It is fast and I find it very simple to use. The only requirement is that you have a Sun Online Account and you get it for free here. With the your free account you will have access to security and driver patches. If you want access to all patches you need to purchase a service plan.

After you do the install you need to edit /etc/pca.conf

Here is an example of mine:
#####PCA.CONF
patchdir=/sunpatches
backdir=/sunpatches/backdir
xrefdir=/var/sadm/pca
xrefown
syslog=user
x#safe=1
###Sun Account
user=XXXXXX
passwd=XXXXX
###


If you haven’t patched your system in a while the list may be quite long. When we only want to see the missing security patches we run pca like this

502 $ sudo pca -l missings
Downloading xref file to /var/sadm/pca/patchdiag.xref
Trying http://sunsolve.sun.com/patchdiag.xref (1/1)
Using /var/sadm/pca/patchdiag.xref from Sep/17/09
Host: stewie-griffin (SunOS 5.10/Generic_141414-07/sparc/sun4u)
List: missings

Patch  IR   CR RSB Age Synopsis
------ -- - -- --- --- -------------------------------------------------------
119254 66 < 70 RS-  15 SunOS 5.10: Install and Patch Utilities Patch

Now to install the patches all you have to do is:

502 $ sudo pca -i missings

Hope this helps. -Brent

Change default PATH in Solaris 10

Next item is the default PATH for the root user and regular users. You can set this in the files

/etc/default/login
/etc/default/su

Please feel free to be pedantic and set PATH and SUPATH in both of those files to something useful thus :
PATH=/usr/sbin:/usr/bin:/usr/dt/bin:/usr/openwin/bin:/usr/ccs/bin:/usr/local/sbin:/usr/local/bin

Solaris 10 Slow SSH login

I was having a problem with ssh taking almost 45secs to log into one of my Solaris 10 boxes. What I found out was for some reason it was taking forever to do dns resolution. What I did to fix it was adding this to /etc/ssh/sshd_config

LookupClientHostnames no
GSSAPIAuthentication no

Then do a restart
Makre sure you check for typos or ssh will not restart and you will have to login via console to fix it.

svcadm restart network/ssh

Wednesday, September 16, 2009

Create a SSH tunnel

This will allow you to tunnel traffic through a firewall.
Example tunnel Service Manager Client that uses port 32001

ssh -N -p 22 brent@183.40.33.34 -L 32001/localhost/32001

Here is the break down of the command:
  • ssh - the actual SSH commad
  • -N tells SSH we don't want to execute a remote command. Not terribly necessary, but makes it safer.
  • brent@183.40.33.34 - account and SSH host info. user name will at server 183.40.33.34
  • -L 32001/localhost/32001 This one creates the tunnel. It tells SSH to forward traffic from port 32001 on the local machine to port 32001 on the remote machine.

Now you can load up Service Manager and connect to localhost instead of 183.40.33.34

Very helpful VI commands

Remove Blank Lines
  • :g/^%/d

Remove carriage returns ^M from lines

  • :%s/.$//g

Remove lines that start with #

  • :g/^\#/d

Changing the IP / Hostname on Solaris 10

Changing the IP on Solaris 10 requires editing two files:
1. /etc/hosts

If you are changing network address, you will need to change the defualt gateway address in the file:
2. /etc/defaultrouter

Changing the hostname now only requires editing these files:
1. /etc/hosts
2. /etc/nodename
3. /etc/hostname.
4. svcadm restart network/physical
  • is the driver name followed by the instance number of the interface. ie. hme0, bge0, ce0, qfe0
  • You can find all your network interfaces by drivername and instance# by running the following command: prtconf -D grep network

Reset ALOM password for a Sun v445

  1. Boot and log in as root.

Use the scadm command to reset the admin password:

a) cd /usr/platform/`uname -i`/sbin
b) ./scadm userpassword admin

Use the escape sequence "#." to get system back to the alom login
prompt.


You can now log into the admin account using the password from
that you just set.