Skip to main content

Posts

Showing posts with the label Linux

Make tftpd-hpa play nicely with Cisco

The following was tested on Ubuntu 11.10. This is completely insecure, make sure it is confined to a LAN environment, i.e. not publicly accessibly.  apt-get install tftpd-hpa mkdir /tftp chmod 777 /tftp nano /etc/default/tftpd-hpa # /etc/default/tftpd-hpa TFTP_USERNAME="tftp" TFTP_DIRECTORY="/tftp" TFTP_ADDRESS="0.0.0.0:69" TFTP_OPTIONS="--secure --create -v" service tftpd-hpa restart  --create is needed to allow client to create new file. Otherwise you will get error stating 'File does not exist' or similar. --secure is so that the client does not need to specify an absolute path such as /tftp/file. The root of the tftp server becomes TFTP_DIRECTORY. -v is for verbose logging in /var/syslog culv-lns1#copy run tftp Address or name of remote host []? 10.2.2.40 Destination filename [culv-lns1-confg]? !! 1446 bytes copied in 0.168 secs (8607 bytes/sec) _________________________________________________ ...

Backup OpenLDAP Ubuntu

The default database location is /usr/lib/ldap It is recommended to backup to LDIF so it is transportable. Use slapcat to export. slapcat -v -l /backups/ldapbackup.ldif To restore use slapadd. cd /usr/lib/ldap rm * slapadd -l ldapbackup.ldif -v is verbose output -l specifies the ldif format

Delete Files Older Than x Days

Applies to FreeBSD and Linux. /mnt       /backup1                    /server1                               /folder1                               /folder2                               /backup1.tar.gz                            /server2                    /server3 find /mnt/backup1 -maxdepth 2 -name '*.gz' -mtime +7 -exec rm {} \; This will find and remove files that are 7 days old. It will search 2 folders deep from /mnt/backup1. It will not search folder1 or folder2. The single quotes around the name search string are required at least on FreeBSD.

HP SNMP agents and Ubuntu

This will allow you to monitor HP hardware, i.e. RAID controller, degraded disk etc. This was done on Ubuntu 10.04 wget http://downloads.linux.hp.com/SDR/downloads/bootstrap.sh chmod +x bootstrap.sh ./bootstrap.sh -r ProLiantSupportPack (this adds the HP repo to apt's sources) wget http://downloads.linux.hp.com/SDR/downloads/ProLiantSupportPack/GPG-KEY-ProLiantSupportPack apt-key add GPG-KEY-ProLiantSupportPack aptitude update apt-get install  hp-snmp-agents apt-get install net-snmp (or apt-get install snmp for later versions ) /sbin/hpsnmpconfig - Follow the prompts nano /etc/default/snmpd # modify this line, replacing x.x.x.x with your public facing IP if needed SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -g snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1 x.x.x.x' ########################################## Restart snmp /etc/init.d/snmpd restart Start the agents! /etc/init.d/hp-snmp-agents start Test with snmpwalk -v 1 -c rocom loc...

SCP / SSH without password

To be able to log into a remote linux host without a password, you must generate a public / private key pair on the local host and copy the public key to the remote host. You would do this if you wanted to SCP some files via a script perhaps. First, generate the key pair on the host that you are connecting from. ssh-keygen -t dsa Accept defaults.. can put passphrase if you wish for extra security. Copy id_dsa.pub to the remote host somewhere. Then add it to the authorized_keys file under the home directory of the user that you are trying to log in as. For instance if you are wanting to send a file to the remote server as user 'bob'... copy the id_dsa.pub file to /tmp on the remote server log in to the remote server as bob cat /tmp/id_dsa.pub >> ~/.ssh/authorized_keys Now you should be able to ssh or scp something to the remote host and not be prompted for a password.