Configure Linux Network Interface

Red Hat/Centos
Edit interface settings by editing the “/etc/sysconfig/network-scrips/ifcfg-eth0” file. The following settings will configure an interface to have a static IP address:

DEVICE=eth0
BOOTPROTO=none
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=192.168.1.27
USERCTL=no

The following settings will configure an interface to use DHCP:

Continue reading “Configure Linux Network Interface”

Configure SSH for Public Key Login

Some quick notes on creating and using a key pair for SSH logon.

1. Generate key pair on the client.

ssh-keygen -t rsa -b 2048

2. Enter a passphrase when prompted. If you do not want a password so that you can use this key pair for automating logons just press Enter twice.
3. Copy the public key from the client to the server

scp ./ssh/id_rsa.pub username@server:.ssh/authorized_keys

The ssh-copy-id command, if it is available, can be used to copy the public key to the server as well.

ssh-copy-id username@server

4. Secure the .ssh folder on the server

chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

Change Linux Hostname

Redhat/CentOS
Edit the line that starts with “HOSTNAME” in the /etc/sysconfig/network file to reflect the new name

HOSTNAME=host.domain.com

Debian/Ubuntu
Echo the new host name to “/etc/hostname”

echo “host.example.com” > /etc/hostname

All Distros
For both types of distributions update the “/etc/hosts” file so that the new name points to the loopback

127.0.0.1       localhost
127.0.1.1       host.example.com localhost