Tuesday, July 31, 2012

expect a pubkey

i have a pubkey. i need to put it all over the place.
but, i have my pubkey on some systems.

sigh.

first, i cat my favorite pubkeys into authorized_keys2, then i strip my dns zone file and get all my ip addresses. then i feed that list into this script. if the systems blink, i attempt to scp to them. if i get a password prompt, expect will throw the "i already know it password" in and copy over my keys. yeah. you can get fancy and do other things, but this is a start.

#!/bin/bash

for ip_addr in $(cat strippedzonefile) ; do

ping -q -c 1 $ip_addr &&

expect -c "
spawn scp /my/authorized_keys2 account@$ip_addr:/that/account/.ssh/authorized_keys2
expect \"?assword:*\"
send -- \"securepassword\r\"
expect eof
 "
done

nfs barfs

i need to re-export an nfs mount because i need to. i do my usual /etc/exports editing. and then nfsd barfs...

root@server:~# exportfs -ra
exportfs: Warning: /my/export does not support NFS export.

why?

Of course...
/etc/default/nfs-kernel-server
needs this line...

REEXPORT_NFS="yes"
then re-start nfs services, statd junk and portmap.

root@server:~# exportfs -ra

no error. nice. or just install unfs3.

Monday, July 30, 2012

strip ips from zonefile

so i want to strip ips from a zone file. easy.
dump it. scp it. whatever.


#!/bin/bash
echo "enter zone file"
read zonefile    
fileName=`pwd`"/$zonefile"

if [ -f "$zonefile" ] ; then

sed -n 's/\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}/\nip&\n/gp' $zonefile | grep ip | sed 's/ip//'| sort | uniq > stripped

fi

no frills scp & execute command script

1000 machines need a file and a command run.
some machines are up. some are not.

first thing, pubkey them. done.

now, what to do about that file and the command?

my file is called, oh, file. it is in ~ . somewhere.
drop a file, say, computers in pwd.

first, check if the computers are alive. then drop the file. then run whatever's in the file.

#!/bin/bash

for ip_addr in $(cat computers) ; do
  ping -q -c 1 $ip_addr && \ 
  scp -r ~/somewhere/file toor@$ip_addr:/tmp && \ 
  ssh -l toor $ip_addr "bash -c \"/tmp/file \""
done

if you work by the hour, then this script would make you useless. if you're salaried, go get some coffee.

Thursday, July 26, 2012

i don't care about keys

well.  i do and sometimes i don't.  let's just suspend all those, do you want to accept rsa key prompts, shall we?

[systemwide]
in /etc/ssh/ssh_config (global client conf file) add stanza:

Host 192.168.168.*
   StrictHostKeyChecking no
   UserKnownHostsFile=/dev/null

* This may be done by subnet or host.

&

[per session]
$ ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no \
uid@192.168.168.192

Wednesday, June 27, 2012

change all those perms

So you need to change the uid on all files owned by user. Do the following as root:
# find / -uid 1500 -gid 100 -exec chown 15038:101 {} \;

A breakdown is as follows:

find / -uid 1500 -gid 100 -exec chown 1500:101 {} \;
^    ^      ^        ^       ^
|    |      |        |       |
|    |      |        |       | 
|    |      |        |       |
|    |      |        |       do this chown new userid:group {all files found}
|    |      |        |
|    |      |        user's primary group
|    |      |
|    |      userid
|    |
|    filesystem
|
command

Wednesday, May 30, 2012

solaris 9 u4 & studio 11

are not compatible.
# ./installer

Exception in thread "Thread-28" java.lang.NoClassDefFoundError: com/sun/install/panels/ComponentSelectionListener
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2427)
        at java.lang.Class.getDeclaredMethod(Class.java:1935)
        at java.awt.Component.isCoalesceEventsOverriden(Component.java:5723)
        at java.awt.Component.access$100(Component.java:162)
        at java.awt.Component$2.run(Component.java:5677)
        at java.awt.Component$2.run(Component.java:5675)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.Component.checkCoalescing(Component.java:5674)
        at java.awt.Component.(Component.java:5643)
        at java.awt.Container.(Container.java:245)
        at javax.swing.JComponent.(JComponent.java:576)
        at javax.swing.JPanel.(JPanel.java:65)
        at javax.swing.JPanel.(JPanel.java:92)
        at javax.swing.JPanel.(JPanel.java:100)
        at com.sun.wizards.core.WizardComponent.(WizardComponent.java:159)
        at com.sun.wizards.core.WizardComponent.(WizardComponent.java:145)
        at com.sun.wizards.core.WizardLeaf.(WizardLeaf.java:78)
        at com.sun.install.panels.ComponentPanel.(ComponentPanel.java:144)
        at com.sun.install.products.CreateSimpleUninstaller.createSimpleUninstallerTree(CreateSimpleUninstaller.java:42)
        at com.sun.install.products.UninstallArchiveCreator.writeArchiveFile(UninstallArchiveCreator.java:537)
        at com.sun.install.products.UninstallArchiveCreator.writeArchive(UninstallArchiveCreator.java:317)
        at com.sun.install.products.UninstallUnit.install(UninstallUnit.java:740)
        at com.sun.install.products.Product.performInstallation(Product.java:649)
        at com.sun.install.tasks.ProductTask.perform(ProductTask.java:153)
        at com.sun.wizards.core.Sequence.perform(Sequence.java:343)
        at com.sun.wizards.core.SequenceManager.run(SequenceManager.java:226)
        at java.lang.Thread.run(Thread.java:619)
well. just take away my spoons.

download jdk-1_5_0_21-solaris-sparc.sh from here http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html#jdk-1.5.0_21-oth-JPR. and...

# mv /usr/java /usr/java1.4
# ln -s /usr/jdk1.5.0_21 /usr/java