Showing posts with label RHEL 5. Show all posts
Showing posts with label RHEL 5. Show all posts

Easier Passwordless SSH with ssh-copy-id

You may be familiar with the many steps involved in setting up Passwordless SSH for an Oracle cluster but there is a utility that simplifies the process considerably: ssh-copy-id.

First generate the public and private keys using ssh-keygen as usual:
oracle@dbserver-1$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/oracle/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Press enter key]
Your identification has been saved in /home/oracle/.ssh/id_rsa.
Your public key has been saved in /home/oracle/.ssh/id_rsa.pub.
The key fingerprint is:
33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 oracle@dbserver-1
After that you can append the key values and set the proper permissions easily using ssh-copy-id:
oracle@dbserver-1$ ssh-copy-id -i ~/.ssh/id_rsa.pub dbserver-2
oracle@dbserver-2's password:
Now try logging into the machine, with "ssh 'dbserver-2'", and check in:

.ssh/authorized_keys

to make sure we haven't added extra keys that you weren't expecting.
Now you are able to ssh into the remote server without a password:
oracle@dbserver-1$ ssh dbserver-2
Last login: Fri Aug 16 14:27:56 PDT 2013 from 192.168.1.2

oracle@dbserver-2$

How to make Ethernet settings on Linux persist after a reboot

Ethtool is a Linux utility that displays and changes Ethernet card settings. For example, to turn on flow control for Ethernet device 5 you can issue the following command:
ethtool –A eth5 tx on rx on
The problem is that these settings are lost on reboot of a server. While there is no way to make these settings persistent using ethtool by itself, you can make them persistent with a script. I found that the script /etc/sysconfig/network-scripts/ifup-ethpost checks for a script called /sbin/ifup-local on boot. If it exists then it is run once for each Ethernet device, and the device name is passed in as an argument. In my particular case I needed to turn on flow control for Ethernet devices 4 and 5 so I created the script and put the following piece of code into it:
#!/bin/bash
case "$1" in
 eth[45])
  /sbin/ethtool -A $1 rx on tx on
  ;;
esac
exit 0
You must also make sure that the script is executable or it will not run:
chmod +x /sbin/ifup-local
I have also determined that the calling script is named /etc/sysconfig/network-scripts/ifup-post on RHEL 5.6.

Quickly and Simply Reconfiguring a UNIX Server using sys-unconfig

Sys-unconfig is a useful utility for Solaris and Linux that allows you to reconfigure your networking. It is easier than doing it manually, which involves editing some or all of the following files depending upon the operating system and version:
  • /etc/defaultrouter
  • /etc/dladm/*
  • /etc/dumpadm.conf
  • /etc/hostname
  • /etc/inet/hosts
  • /etc/nodename
  • /etc/nsswitch.conf
  • /etc/resolv.conf
Sys-unconfig is used for restoring a server's configuration back to its original state, before it was configured. It "unconfigures" the following:
  • Host Name
  • Domain Name
  • Time Zone
  • IP Address
  • IP Subnet Mask
  • Root Password

How to run a script on reboot on Red Hat Linux

This technique can be useful for running a service on reboot. It has been tested and known to work on Red Hat Linux 5.5 but will probably work on most versions of Linux since they mostly use a similar system of starting services at reboot.

You will need to put a wrapper script for your service under /etc/rc.d that must be owned by root. By convention it does not need an extension. In this example my wrapper script is called "myscript". The header is required to have a certain format (see below for an example) and the operating system will check for certain tokens in the comments. You can create different functions in the script corresponding to different conditions such as start, stop, status, restart, or reload. To keep it simple I will just deal with start and stop here. The following script is an example of a wrapper script for the script that you want to run. The actual script that you run will be called from this script. In this example I have called the script to be run "myservice.sh".

Clean the header of an ASM volume so it can be reused

As root run the dd command on the device, which will write zeroes to the first 40 MB, wiping the header.

Example:
dd if=/dev/zero of=c9t50060E8006CFCC11d9s0 bs=1048576 count=40