General

From Wiki.voidnet.us

Jump to: navigation, search

Contents

[edit] Space usage

 du -h --max-depth=1 /


On a Solaris box:

 du -s `ls -l|grep drwx|awk {'print $9'}

[edit] Perl CPAN shell

 perl -MCPAN -e shell

[edit] Increase open file handler limit

  • Edit /etc/sysctl.conf.
 fs.file-max=16384
 kernel.sem = 256 65535 256 512
  • Change kernel Settings
 echo 256 65535 256 512 > /proc/sys/kernel/sem
 sysctl -w fs.file-max=16384

[edit] NTP stuff

ntpq -p (shows sources)

 /etc/ntp.conf

comment out # --- OUR TIMESERVERS ----- section add ip of dc time server to general config:

   server time.iad1.rackspace.com prefer
   restrict 69.20.0.164 mask 255.255.255.255 nomodify notrap
   server  127.127.1.0     # local clock
   fudge   127.127.1.0 stratum 10

[edit] SSH only root can log in

 sshd_config: #UsePrivilegeSeparation yes  set to no

[edit] RS IPs

 # US/UK Non-Routable:
 10.0.0.0/12 (10.0.0.0/255.240.0.0)
 10.225.225.0/26 (10.225.225.0/255.255.255.192)
 10.235.235.0/26 (10.235.235.0/255.255.255.192)
 10.230.255.0/24 (10.230.255.0/255.255.255.0)
 # General US Rackspace Routable Network:
 64.39.0.0/23 (64.39.0.0/255.255.254.0)
 # General UK Routable Network:
 212.100.225.32/27 (212.100.225.32/255.255.255.224)
 # Backup/Storage/Patching, (Dallas/Fort Worth, US):
 10.250.0.0/23 (10.250.0.0/255.255.254.0)
 10.5.97.0/24 (10.5.97.10/255.255.255.0)

[edit] Urchin Migration Instructions

http://www.google.com/support/urchin45/bin/answer.py?answer=28511&topic=7391


[edit] Reset Urchin Password

 uconf-driver action=set_parameter table=user name="(admin)" ct_password=urchin

[edit] Lower qmail queue life

 /var/qmail/control/queuelifetime

[edit] Webmin Back door

Edit

 /etc/webmin/miniserv.users 

yy p to add new user

Edit

 /etc/webmin/webmin.acl 

yy p to add new user

 changepass.pl /etc/webmin <user> <passwd>

[edit] Check for semephors

 ipcs

Kill a bunch of semephors:

 for i in `ipcs |grep apache |awk '{print $2}'`; do ipcrm -s $i; done

[edit] Tomcat SSL cert install

Generate the pkcs12 file: (After creating the .key and .crt files)

 openssl pkcs12 -export -out keystore.pkcs12 -in www.crt -inkey www.key

Verify new pkcs12 file:

 keytool -list -v -keystore 2006-www.tsscart.com.pkcs12 -keypass SdLTo8k6 -storetype pkcs12

Install Cert in /path/to/tomcat/conf/server.xml

   <Connector address="72.32.6.169" port="443" maxHttpHeaderSize="8192"
              maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
              enableLookups="false" disableUploadTimeout="true"
              acceptCount="100" scheme="https" secure="true"
              clientAuth="false" sslProtocol="TLS"
              keystoreFile="/usr/local/tomcat/conf/certs/2006-www.tsscart.com.pkcs12"
              keystoreType="PKCS12"
              keystorePass="SdLTo8k6"/>

[edit] TCP SYN attack stuff

 net.ipv4.icmp_ignore_bogus_error_responses=1
 net.ipv4.icmp_echo_ignore_broadcasts=1
 net.ipv4.conf.all.log_martians=1
 net.ipv4.tcp_max_syn_backlog="64"
 net.ipv4.tcp_syncookies = 1
 net.ipv4.tcp_syn_retries = 3
 net.ipv4.icmp_echo_ignore_all=0

[edit] Public/private key ssh stuff

 ssh-keygen -b 1024 -C "Comment" -t dsa -f .ssh/id_dsa
 cp .ssh/keyname.pub to recieving machine in .ssh/authorized_keys

Enable

 PubkeyAuthentication yes
 AuthorizedKeysFile      .ssh/authorized_keys

If root set:

 PermitRootLogin yes
 chmod 600 .ssh/authorized_keys

[edit] rpmverify legend

 S - File size differs
 M - Mode differs (permissions)
 5 - MD5 sum differs
 D - Device number mismatch
 L - readLink path mismatch
 U - user ownership differs
 G - group ownership differs
 T - Modification time differs

[edit] After installing vacation on a sendmail box

 ln -s /usr/bin/vacation /etc/smrsh/

[edit] awk foo

grep -R "Postcard.exe" ./* |awk -F: '{ print $1 }' |xargs rm -f

cat /var/log/httpd/access_log | awk {'print $1'} | sort | uniq -c | sort -n | less

[edit] hostname change on a RHEL box

/etc/hosts

/etc/sysconfig-network


[edit] Local tape based backups

To get the interactive version of 'restore', you will need to use the command line switch '-i'. You can also specify which filesystem backup you want to look at (the "file" mentioned in the _How Backup Are Made_section) by using the '-s' switch. Assuming that I have a normal partitioning scheme, the files on my tape will look like this:

  File        Partition     Directory
   1          /dev/hda1       /boot
   2          /dev/hda5       /


This next example assumes that we want to restore an initrd image in /boot from the tape drive.

The first step is to move into the top level of the filesystem where we want to do the restore from. In this case, the filesystem will be "/dev/hda1", which is mounted on our system under "/boot".

 [root@mybox /root]# cd /boot
 [root@mybox /boot]# mt -f /dev/tape rewind
 [root@mybox /boot]# restore -i -s 1 -f /dev/tape


After a short pause, I am now given a prompt that looks similar to this:


 restore >

At this prompt, I can move around the filesystem on the tape the same as if it was on my hard drive. I can use the ls' and 'cd' commands just the same as if I was at a regular shell prompt.

When I find the file (or directory) that I want to extra, I use the 'add' command, then run 'extract to pull it off the tape and restore it to the hard drive.

Here's a sample run to restore the /boot/initrd-2.2.14-12.10RS.img file from a tape drive to the hard drive:

 restore > ls
 .:
 .rackspace/                 lost+found/
 System.map                  map
 System.map-2.2.14-12.10RS   module-info
 boot.0300                   module-info-2.2.14-12.10RS
 boot.b                      os2_d.b
 chain.b                     vmlinux-2.2.14-12.10RS
 initrd-2.2.14-12.10RS.img   vmlinuz
 restore > add initrd-2.2.14-12.10RS.img
 restore > extract
 You have not read any tapes yet.
 Unless you know which volume your file(s) are on you should start
 with the last volume and work towards the first.
 Specify next volume #: 1
 set owner/mode for '.'? [yn] y
 restore > quit

For single tape tape drives, you only have one "volume", so when you are asked to specify the next volume, you simply enter "1". The question about setting owner/mode for the directory will restore the backup permissions for everything you have restored from tape to the exact same as they were when the tape was made.

[edit] Strip ^M from windows files

 sed 's/^M/\/g' filename  ^M  is created by hitting <ctrl>-V <ctrl>-M

[edit] Thawt cert logo for customer sites

https://www.thawte.com/cgi/server/authentic.exe

[edit] Snapshot script for crashing boxes

http://www.transcendlinux.com/snapshot-script-for-crashing-boxes

[edit] 20 highest failed connections to server

 grep Failed /var/log/secure* | sed -e "s/^.*from //g" | sed -e "s/ port.*$//g" | sort -n | uniq -c | sort -nr | head -20

[edit] Wicked 1 liners

 rm -f times.out remotequeuetoa.out topsourceips.out; \
 for msg in $(qmHandle -R | head -100 | grep --binary-files=text ^[0-9] \
 | cut -f1 -d" ") ; do echo Found message: $msg ; zgrep -h $msg \
 /usr/local/psa/var/log/maillog* | grep "uid 48" | \
 awk '{print $2"/"$1"/"2007":"$3}' | cut -f1-3 -d":" \
 >> times.out ; done ; echo Searching web logs ; \
 for log in $(locate access_log | egrep -v "psa|mnt") ; \
 do for time in `cat times.out` ; do echo "Searching for $time in $log" ; \
 zgrep -H $time $log | egrep -v "webmail|sitebuilder" | egrep "POST|PUT" \
 | grep " 200 " >> remotequeuetoa.out ; done ; done ; cat remotequeuetoa.out \
 | cut -f2 -d":" | awk '{print $1}' | sort -n | uniq -c | sed -e "s/^ *//g" \
 | sort -nr > topsourceips.out
 
 grep "POST" remotequeuetoa.out | sed -e "s/ HTTP.*$//g" -e "s/\/statistics\/logs.*\"POST / /g" -e
 "s^\/var\/www\/vhosts\///g" | sed -e "s/?.*$//g" | grep -v " 404 " | sort | uniq -c | sed -e "s/^
 *//g" | sort -nr | head -30
 zcat /etc/httpd/logs/*/access_log070308.gz | grep POST | awk '{ print $7 }' | sort | uniq -c | sort -rn
 ipcalc -n `ifconfig|grep inet|grep 10.22|awk {'print $2'}|sed 's/addr://'`"/21"|sed 's/NETWORK=//'

[edit] Fix a broke ass ext3 journal

  1. umount /dev/hda3
  2. tune2fs -O ^has_journal /dev/hda3
  3. e2fsck /dev/hda3
  4. tune2fs -j /dev/hda3
  5. mount /dev/hda3


[edit] Turn off DNS recursion

 option {
   recursion no;
 }

[edit] Configure SYSLOG for PIX

edit /etc/sysconfig/syslog

add SYSLOGD_OPTIONS="-x -r -m 0"

edit /etc/syslog.conf

add local4.* /var/log/pix.log

change messages *.info;mail.none;authpriv.none;cron.none;local4.none /var/log/messages

[edit] Pix varialbes for timeout

 fw# show timeout
 timeout xlate 3:00:00
 timeout conn 1:00:00 half-closed 0:10:00 udp 0:02:00 rpc 0:10:00 h225 1:00:00

[edit] vi search and replace

 %s/www.8e6.com \[/www.8e6.com - \[/g

[edit] Redhat SRPMS

ftp://ftp.redhat.com/pub/redhat/linux/

[edit] Cool IP list

http://ip.ludost.net/

[edit] Some rsync for good measure

 rsync --archive --update --rsh=ssh /path/to/files user@dest_ip:/place/to/put/files

[edit] Install Urchin on FreeBSD 6.x

 portsnap fetch
 portsnap extract
 install /usr/ports/misc/compat5x
 install urchin 5x tarball

[edit] openssl

Verify .key/.crt

 openssl rsa -in 2006-admin.farmsresearch.com.key -noout -modulus
 openssl x509 -in ../ssl.crt/2006-admin.farmsresearch.com.crt -noout -subject -dates

Generate key/csr

 openssl genrsa 1024 > /etc/httpd/conf/ssl.key/nameofkey.key
 openssl req -new -key /etc/httpd/conf/ssl.key/nameofkey.key > /etc/httpd/conf/ssl.csr/nameofcsr.csr

Self Signed CRT:

 openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt


[edit] pam_mysql virtual vsftpd users

/etc/pam.d/vsftpd

 #%PAM-1.0
 auth            sufficient      pam_mysql.so user=vsftpd passwd=BuogOcnoir host=localhost db=bvi2 table=users usercolumn=username passwdcolumn=password crypt=2 verbose=1
 account         sufficient      pam_mysql.so user=vsftpd passwd=BuogOcnoir host=localhost db=bvi2 table=users usercolumn=username passwdcolumn=password crypt=2 verbose=1
 auth            optional        pam_listfile.so item=user sense=deny file=/etc/vsftpd.ftpusers onerr=succeed
 auth            requisite       pam_stack.so service=system-auth
 auth            optional        pam_shells.so
 account         requisite       pam_stack.so service=system-auth
 session         requisite       pam_stack.so service=system-auth

/etc/vsftpd/vsftpd.conf

 # Example config file /etc/vsftpd/vsftpd.conf
 #
 # The default compiled in settings are fairly paranoid. This sample file
 # loosens things up a bit, to make the ftp daemon more usable.
 # Please see vsftpd.conf.5 for all compiled in defaults.
 #
 # READ THIS: This example file is NOT an exhaustive list of vsftpd options.
 # Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
 # capabilities.
 #
 # Allow anonymous FTP? (Beware - allowed by default if you comment this out).
 # Anonymous access off by default -- Rackspace
 anonymous_enable=NO
 #
 # Uncomment this to allow local users to log in.
 local_enable=YES
 #
 # Uncomment this to enable any form of FTP write command.
 write_enable=YES
 #
 # Default umask for local users is 077. You may wish to change this to 022,
 # if your users expect that (022 is used by most other ftpd's)
 local_umask=022
 #
 # Uncomment this to allow the anonymous FTP user to upload files. This only
 # has an effect if the above global write enable is activated. Also, you will
 # obviously need to create a directory writable by the FTP user.
 #anon_upload_enable=YES
 #
 # Uncomment this if you want the anonymous FTP user to be able to create
 # new directories.
 #anon_mkdir_write_enable=YES
 #
 # Activate directory messages - messages given to remote users when they
 # go into a certain directory.
 dirmessage_enable=YES
 #
 # Activate logging of uploads/downloads.
 xferlog_enable=YES
 #
 # Make sure PORT transfer connections originate from port 20 (ftp-data).
 connect_from_port_20=YES
 #
 # If you want, you can arrange for uploaded anonymous files to be owned by
 # a different user. Note! Using "root" for uploaded files is not
 # recommended!
 #chown_uploads=YES
 #chown_username=whoever
 #
 # You may override where the log file goes if you like. The default is shown
 # below.
 #xferlog_file=/var/log/vsftpd.log
 #
 # If you want, you can have your log file in standard ftpd xferlog format
 xferlog_std_format=YES
 #
 # You may change the default value for timing out an idle session.
 #idle_session_timeout=600
 #
 # You may change the default value for timing out a data connection.
 #data_connection_timeout=120
 #
 # It is recommended that you define on your system a unique user which the
 # ftp server can use as a totally isolated and unprivileged user.
 #nopriv_user=ftpsecure
 #
 # Enable this and the server will recognise asynchronous ABOR requests. Not
 # recommended for security (the code is non-trivial). Not enabling it,
 # however, may confuse older FTP clients.
 #async_abor_enable=YES
 #
 # By default the server will pretend to allow ASCII mode but in fact ignore
 # the request. Turn on the below options to have the server actually do ASCII
 # mangling on files when in ASCII mode.
 # Beware that turning on ascii_download_enable enables malicious remote parties
 # to consume your I/O resources, by issuing the command "SIZE /big/file" in
 # ASCII mode.
 # These ASCII options are split into upload and download because you may wish
 # to enable ASCII uploads (to prevent uploaded scripts etc. from breaking),
 # without the DoS risk of SIZE and ASCII downloads. ASCII mangling should be
 # on the client anyway..
 #ascii_upload_enable=YES
 #ascii_download_enable=YES
 #
 # You may fully customise the login banner string:
 ftpd_banner=Welcome to the R-ethink dropbox
 #
 # You may specify a file of disallowed anonymous e-mail addresses. Apparently
 # useful for combatting certain DoS attacks.
 #deny_email_enable=YES
 # (default follows)
 #banned_email_file=/etc/vsftpd/vsftpd.banned_emails
 #
 # You may specify an explicit list of local users to chroot() to their home
 # directory. If chroot_local_user is YES, then this list becomes a list of
 # users to NOT chroot().
 #chroot_list_enable=YES
 # (default follows)
 #chroot_list_file=/etc/vsftpd.chroot_list
 #
 # You may activate the "-R" option to the builtin ls. This is disabled by
 # default to avoid remote users being able to cause excessive I/O on large
 # sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
 # the presence of the "-R" option, so there is a strong case for enabling it.
 #ls_recurse_enable=YES
 pam_service_name=vsftpd
 userlist_enable=YES
 #enable for standalone mode
 listen=YES
 tcp_wrappers=YES
 # Added for pam_mysql
 #nonpriv_user=vsftpd
 #virtual_use_local_privs=YES
 #chroot_local_user=YES
 #guest_enable=YES
 #guest_username=vsftpd
 #local_root=/home/vsftpd/$USER
 #user_sub_token=$USER
 #secure_chroot_dir=/var/run/vsftpd
 #user_config_dir=/etc/vsftpd_user_conf
 
 #chroot_local_user=YES
 #secure_chroot_dir=/var/run/vsftpd
 pam_service_name=vsftpd
 guest_enable=YES
 guest_username=vsftpd
 local_root=/home/vsftpd/$USER
 user_sub_token=$USER
 virtual_use_local_privs=YES
 #user_config_dir=/etc/vsftpd_user_conf

MySQL Table Structure:

 mysql> describe users;
 +----------+-------------+------+-----+---------+-------+
 | Field    | Type        | Null | Key | Default | Extra |
 +----------+-------------+------+-----+---------+-------+
 | username | varchar(20) | YES  |     | NULL    |       | 
 | password | varchar(20) | YES  |     | NULL    |       | 
 +----------+-------------+------+-----+---------+-------+

And thats it!

[edit] Verizon EVDO PC5750 PC Card setup

Plug the card into your PC card slot and check dmesg for the device:

 ohci_hcd 0000:16:00.1: OHCI Host Controller
 ohci_hcd 0000:16:00.1: new USB bus registered, assigned bus number 9
 ohci_hcd 0000:16:00.1: irq 20, io mem 0x80001000
 usb usb9: configuration #1 chosen from 1 choice
 hub 9-0:1.0: USB hub found
 hub 9-0:1.0: 1 port detected
 usb 8-1: new full speed USB device using ohci_hcd and address 2
 usb 8-1: configuration #1 chosen from 1 choice
 cdc_acm 8-1:1.0: ttyACM0: USB ACM device

We see here that the device is ttyACM0. Now add the following to your /etc/modprobe.conf:

 #Broadband card
 options usbserial vendor=0x1410 product=0x2110
 options airprime endpoints=1

Make sure that the usbserial and airprime kernel modules are loaded. Now create the following files:

/etc/ppp/peers/verizon:

 noauth
 connect '/usr/sbin/chat -v -f /etc/ppp/peers/verizon_chat'
 defaultroute
 usepeerdns
 ttyACM0
 230400
 local
 debug
 -detach

ttyACM0 is to be substituted by whatever your device name is.

/etc/ppp/peers/verizon_chat:

 ABORT 'NO CARRIER' ABORT 'ERROR' ABORT 'NO DIALTONE' ABORT
 'BUSY' ABORT 'NO ANSWER'
  ATZ
 OK-AT-OK ATDT#777
 CONNECT \d\c

Now just use pppd to start the connection:

 [root@learned]# pppd call verizon
 Serial connection established.
 using channel 3
 Using interface ppp0
 Connect: ppp0 <--> /dev/ttyACM0
 sent [LCP ConfReq id=0x1 <asyncmap 0x0> <magic 0x93aa9b0b> <pcomp> <accomp>]
 rcvd [LCP ConfReq id=0x6 <mru 1500> <asyncmap 0x0> <magic 0xa75f357> <pcomp> <accomp>]
 sent [LCP ConfAck id=0x6 <mru 1500> <asyncmap 0x0> <magic 0xa75f357> <pcomp> <accomp>]
 rcvd [LCP ConfAck id=0x1 <asyncmap 0x0> <magic 0x93aa9b0b> <pcomp> <accomp>]
 sent [CCP ConfReq id=0x1 <deflate 15> <deflate(old#) 15>]
 sent [IPCP ConfReq id=0x1 <compress VJ 0f 01> <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
 rcvd [LCP DiscReq id=0x7 magic=0xa75f357]
 rcvd [IPCP ConfReq id=0x2 <addr 66.174.46.4>]
 sent [IPCP ConfAck id=0x2 <addr 66.174.46.4>]
 rcvd [LCP ProtRej id=0x8 80 fd 01 01 00 0c 1a 04 78 00 18 04 78 00]
 Protocol-Reject for 'Compression Control Protocol' (0x80fd) received
 rcvd [IPCP ConfRej id=0x1 <compress VJ 0f 01>]
 sent [IPCP ConfReq id=0x2 <addr 0.0.0.0> <ms-dns1 0.0.0.0> <ms-dns3 0.0.0.0>]
 rcvd [IPCP ConfNak id=0x2 <addr 70.218.107.232> <ms-dns1 69.78.96.14> <ms-dns3 66.174.92.14>]
 sent [IPCP ConfReq id=0x3 <addr 70.218.107.232> <ms-dns1 69.78.96.14> <ms-dns3 66.174.92.14>]
 rcvd [IPCP ConfAck id=0x3 <addr 70.218.107.232> <ms-dns1 69.78.96.14> <ms-dns3 66.174.92.14>]
 local  IP address 70.218.107.232
 remote IP address 66.174.46.4
 primary   DNS address 69.78.96.14
 secondary DNS address 66.174.92.14
 Script /etc/ppp/ip-up started (pid 8585)
 Script /etc/ppp/ip-up finished (pid 8585), status = 0x0
 Terminating on signal 2
 Connect time 1.9 minutes.
 Sent 13027 bytes, received 84 bytes.
 Script /etc/ppp/ip-down started (pid 8850)
 sent [LCP TermReq id=0x2 "User request"]
 rcvd [LCP TermAck id=0x2]

I did have to place the nameservers from /etc/ppp/resolve.conf into my /etc/resolve.conf before I could do name lookups as my /etc/resolve.conf referred to internal IP space for the nameserver.

And that's it, now I can use my work provided Verizon wireless PC card when I'm out and about and need interwebs.

Personal tools