Se afișează postările cu eticheta LINUX. Afișați toate postările
Se afișează postările cu eticheta LINUX. Afișați toate postările

vineri, 17 februarie 2017

SSH login without password

Your aim

You want to use Linux and OpenSSH to automate your tasks. Therefore you need an automatic login from host A / user a to Host B / user b. You don't want to enter any passwords, because you want to call ssh from a within a shell script.

How to do it

First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:
a@A:~> ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/a/.ssh/id_rsa): 
Created directory '/home/a/.ssh'.
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/a/.ssh/id_rsa.
Your public key has been saved in /home/a/.ssh/id_rsa.pub.
The key fingerprint is:
3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A
Now use ssh to create a directory ~/.ssh as user b on B. (The directory may already exist, which is fine):
a@A:~> ssh b@B mkdir -p .ssh
b@B's password: 
Finally append a's new public key to b@B:.ssh/authorized_keys and enter b's password one last time:
a@A:~> cat .ssh/id_rsa.pub | ssh b@B 'cat >> .ssh/authorized_keys'
b@B's password: 
From now on you can log into B as b from A as a without password:
a@A:~> ssh b@B
A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:
  • Put the public key in .ssh/authorized_keys2
  • Change the permissions of .ssh to 700
  • Change the permissions of .ssh/authorized_keys2 to 640

vineri, 4 octombrie 2013

Building a custom kernel

This example is for Fedora Core 18

I. Install necessary packages:

#su -c 'yum install rpmdevtools yum-utils'
#su -c 'yum install ncurses-devel'
#su -c 'yum install qt3-devel libXi-devel'

II. Get the Source
OBS. Do not build packages as root

1. Prepare a RPM package building environment in your home directory. Run the following command: 

rpmdev-setuptree

2.Download the kernel-<version>.src.rpm file. Enable the appropriate source repositories with the --enablerepo switch. (yumdownloader --enablerepo=repo_to_enable --source kernel)

 
yumdownloader --source kernel

3.Install build dependencies for the kernel source with the yum-builddep command (root is required to install these packages):

su -c 'yum-builddep kernel-<version>.src.rpm'

4. Install kernel-<version>.src.rpm with the following command

rpm -Uvh kernel-<version>.src.rpm


Prepare the Kernel Source Tree

cd ~/rpmbuild/SPECS
rpmbuild -bp --target=$(uname -m) kernel.spec


Preserve the original tree :

export arch=x86_64 # replace x86_64 with your arch
export ver=3.7 # replace 3.1 with your kernel version
export subver=4-204
export fedver=fc16 # replace fc16 with your fedora version
cp -r ~/rpmbuild/BUILD/kernel-$ver.$fedver ~/rpmbuild/BUILD/kernel-$ver.$fedver.orig
cp -al ~/rpmbuild/BUILD/kernel-$ver.$fedver ~/rpmbuild/BUILD/kernel-$ver.$fedver.new



cd ~/rpmbuild/BUILD/kernel-$ver.$subver.$fedver/linux-$ver.$arch/
cp configs/<desired-config-file> .config
make menuconfig

Copy the config file to ~/rpmbuild/SOURCES/:

cp .config ~/rpmbuild/SOURCES/config-`uname -m`-generic
cd ~/rpmbuild/SPECS
%define buildid .<custom_text>
rpmbuild -bb --with baseonly --with firmware --without debuginfo \
--target=`uname -m` kernel.spec


Install the new kernel
su -c "rpm -ivh $HOME/rpmbuild/RPMS/<arch>/kernel-<version>.<arch>.rpm"



luni, 4 martie 2013

Fedora core installing package groups with yum

Fedora core installing package groups with yum

 
yum is an interactive tool or automated update program which can be used for maintaining systems using rpm (read as RedHat and friends).
It allows you to install single package or group of package. For example let us say you are running a web server with PHP+MySQL. Now you need complete development environment i.e gcc C/C++ compilers, subversion cvs, perl and related libraries. You can install them in one shot with the following command:
# yum groupinstall 'Development Tools'
You can remove all developer tools with the following command:
# yum groupremove 'Development Tools'
Or better update all tools to latest version:
# yum groupupdate 'Development Tools'
You can obtain list of all groups with the following command:
# yum grouplist | less
Output:
Installed Groups:
   Compatibility Arch Support
   Editors
   MySQL Database
   PostgreSQL Database
   System Tools
   Text-based Internet
   Web Server
Available Groups:
   Administration Tools
   Authoring and Publishing
   Compatibility Arch Development Support
   DNS Name Server
   Development Tools
   Eclipse
   Engineering and Scientific
   FTP Server
   GNOME Desktop Environment
   GNOME Software Development
   Games and Entertainment
   Graphical Internet
   Graphics
   Java Development
   KDE (K Desktop Environment)
   KDE Software Development
   Language Support
   Legacy Network Server
   Legacy Software Development
   Mail Server
   Network Servers
   News Server
   Office/Productivity
   Printing Support
   Server Configuration Tools
   Sound and Video
   Windows File Server
 X Software Development
   X Window System
   XFCE
   XFCE Software Development
Done
You can also gather information about all packages that belongs to a group:
# yum groupinfo 'Development Tools'

This is a handy feature, to install or remove software(s). If any one has more information about similar options (w/o front-end) for apt-get command, then please comment it back below.

Linux Creating or Adding New Network Alias To a Network Card

Linux Creating or Adding New Network Alias To a Network Card (NIC)

 
Q. I would like to create alias for my network card (NIC). How do I setup 2 IP address on One NIC? How do I add alias under Centos / Fedora / Debian / Ubuntu Linux?

A. Linux allows you to add additional network address using alias feature. Please note that all additional network IP address must be in same subnet. For example if your eth0 using 192.168.1.5 IP address then alias must be setup using 192.168.1.0/24 subnet.

ifconfig command line

You can use ifconfig command to configure a network interface and alias. For example:
  • eth0 NIC IP 192.168.1.5
  • eth0:0 first NIC alias: 192.168.1.6
To setup eth0:0 alias type the following command as the root user:
# ifconfig eth0:0 192.168.1.6 up
Verify alias is up and running using following command:
# ifconfig -a
# ping 192.168.1.6
However, if you reboot the system you will lost all your alias. To make it permanent you need to add it network configuration file.

Debian / Ubuntu Linux Instructions

You can configure the additional IP addresses automatically at boot with another iface statement in /etc/network/interfaces:
# vi /etc/network/interfaces
Append text as follows:
auto eth0:1
iface eth0:1 inet static
name Ethernet alias LAN card
address 192.168.1.7
netmask 255.255.255.0
broadcast 192.168.1.255
network 192.168.1.0
Save and close the file. Restart the network:
# /etc/init.d/networking restart

Red Hat / RHEL / CentOS / Fedora Linux Instructions

Copy etc/sysconfig/network-scripts/ifcfg-eth0 file as /etc/sysconfig/network-scripts/ifcfg-eth0:0
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
Open file /etc/sysconfig/network-scripts/ifcfg-eth0:0 using vi text editor:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
Find entry that read as follows:DEVICE=eth0
Replace with:DEVICE=eth0:0
Find entry that read as follows:
IPADDR=xxx.xxx.xxx.xxx
Replace it with your actual IP address:
IPADDR=192.168.1.7
At the end your file should like as follows:
DEVICE=eth0:0
IPADDR=192.168.1.7
NETMASK=255.255.255.0
NETWORK=192.168.1.0
ONBOOT=yes
NAME=eth0:0
Open file /etc/sysconfig/network-scripts/ifcfg-eth0 and make sure file does not have a GATEWAY= entry:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Find the entry that read as follows:
GATEWAY=your-ip
Remove or comment it out by prefixing # (hash) :
 # GATEWAY=192.168.1.254
Save the file. Add the GATEWAY= to your /etc/sysconfig/network:
# vi /etc/sysconfig/network
Append or modify GATEWAY entry:
GATEWAY=192.168.1.254
Save the file. Reboot the system or run the following command:
# ifup eth0:0
OR
# service network restart

Red Hat / CentOS / Fedora Multiple IP address range

You can assign multiple ip address range as follows to eth0:
vi /etc/sysconfig/network-scripts/ifcfg-eth0-range0
Append following code from 202.54.112.120 to 202.54.112.140:
IPADDR_START=202.54.112.120
IPADDR_END=202.54.112.140
CLONENUM_START=0
NETMASK=255.255.255.0

Save and close the file.