Tuesday, April 03, 2012

Linux 8 - RPM and yum package management

  • rpm
  • rpm2cpio
  • alien
  • yum
    • /etc/yum.conf
    • /etc/yum.repos.d
  • yum downloader
yum is alike like apt-get is in debian like distribs
yum install open-ssh clients

[root@localhost ovidiu]# yum install openssh-clients
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ch-center.com
 * extras: mirrors.ch-center.com
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: mirrors.ch-center.com
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package openssh-clients.i386 0:4.3p2-82.el5 set to be updated
--> Processing Dependency: openssh = 4.3p2-82.el5 for package: openssh-clients
--> Running transaction check
--> Processing Dependency: openssh = 4.3p2-72.el5_7.5 for package: openssh-askpass
--> Processing Dependency: openssh = 4.3p2-72.el5_7.5 for package: openssh-server
---> Package openssh.i386 0:4.3p2-82.el5 set to be updated
--> Running transaction check
---> Package openssh-askpass.i386 0:4.3p2-82.el5 set to be updated
---> Package openssh-server.i386 0:4.3p2-82.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=========================================================================
 Package                Arch        Version               Repository   Size
=========================================================================
Updating:
 openssh-clients        i386        4.3p2-82.el5          base        455 k
Updating for dependencies:
 openssh                i386        4.3p2-82.el5          base        291 k
 openssh-askpass        i386        4.3p2-82.el5          base         42 k
 openssh-server         i386        4.3p2-82.el5          base        275 k

Transaction Summary
============================================================================
Install       0 Package(s)
Upgrade       4 Package(s)

Total download size: 1.0 M
Is this ok [y/N]: 
Downloading Packages:
(1/4): openssh-askpass-4.3p2-82.el5.i386.rpm         |  42 kB     00:00     
(2/4): openssh-server-4.3p2-82.el5.i386.rpm          | 275 kB     00:00     
(3/4): openssh-4.3p2-82.el5.i386.rpm                 | 291 kB     00:00     
(4/4): openssh-clients-4.3p2-82.el5.i386.rpm         | 455 kB     00:00     
----------------------------------------------------------------------------
Total                                       918 kB/s | 1.0 MB     00:01     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : openssh                                              1/8 
  Updating       : openssh-clients                                      2/8 
  Updating       : openssh-askpass                                      3/8 
  Updating       : openssh-server                                       4/8 
  Cleanup        : openssh                                              5/8 
  Cleanup        : openssh-clients                                      6/8 
  Cleanup        : openssh-askpass                                      7/8 
  Cleanup        : openssh-server                                       8/8 

Updated:
  openssh-clients.i386 0:4.3p2-82.el5                                       

Dependency Updated:
  openssh.i386 0:4.3p2-82.el5          openssh-askpass.i386 0:4.3p2-82.el5  
  openssh-server.i386 0:4.3p2-82.el5  

Complete!
[root@localhost ovidiu]# 

yum remove openssh-clients


Complete!
[root@localhost ovidiu]# yum remove openssh-clients
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package openssh-clients.i386 0:4.3p2-82.el5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================
 Package               Arch       Version             Repository       Size
============================================================================
Removing:
 openssh-clients       i386       4.3p2-82.el5        installed       853 k

Transaction Summary
============================================================================
Remove        1 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Erasing        : openssh-clients                                      1/1 

Removed:
  openssh-clients.i386 0:4.3p2-82.el5                                       

Complete!
[root@localhost ovidiu]# 
[root@localhost ovidiu]# yum remove openssh
Loaded plugins: fastestmirror
Setting up Remove Process
Resolving Dependencies
--> Running transaction check
---> Package openssh.i386 0:4.3p2-82.el5 set to be erased
--> Processing Dependency: openssh = 4.3p2-82.el5 for package: openssh-clients
--> Processing Dependency: openssh = 4.3p2-82.el5 for package: openssh-askpass
--> Processing Dependency: openssh = 4.3p2-82.el5 for package: openssh-server
--> Running transaction check
---> Package openssh-askpass.i386 0:4.3p2-82.el5 set to be erased
---> Package openssh-clients.i386 0:4.3p2-82.el5 set to be erased
---> Package openssh-server.i386 0:4.3p2-82.el5 set to be erased
--> Finished Dependency Resolution

Dependencies Resolved

============================================================================
 Package               Arch       Version             Repository       Size
============================================================================
Removing:
 openssh               i386       4.3p2-82.el5        installed       730 k
Removing for dependencies:
 openssh-askpass       i386       4.3p2-82.el5        installed       9.9 k
 openssh-clients       i386       4.3p2-82.el5        installed       853 k
 openssh-server        i386       4.3p2-82.el5        installed       483 k

Transaction Summary
============================================================================
Remove        4 Package(s)
Reinstall     0 Package(s)
Downgrade     0 Package(s)

Is this ok [y/N]: 
yum will not let you maintain a broken package

yum search openssh



[root@localhost ovidiu]# yum search openssh
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ch-center.com
 * extras: mirrors.ch-center.com
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: mirrors.ch-center.com
============================= Matched: openssh =============================
keychain.noarch : Agent manager for OpenSSH, ssh.com, Sun SSH, and GnuPG
nagios-plugins.i386 : Host/service/network monitoring program plugins for
                    : Nagios
openssh.i386 : The OpenSSH implementation of SSH protocol versions 1 and 2
openssh-askpass.i386 : A passphrase dialog for OpenSSH and X
openssh-clients.i386 : The OpenSSH client applications
openssh-server.i386 : The OpenSSH server daemon
openssh-xinetd.noarch : OpenSSH backup xinetd entry
perl-Net-OpenSSH.noarch : Perl module named Net-OpenSSH
perl-Net-OpenSSH-Parallel.noarch : Run SSH jobs in parallel.
proxytunnel.i386 : Punching holes in HTTP(S) proxy's
pssh.noarch : Parallel version of OpenSSH and related tools
rssh.i386 : Restricted shell for use with OpenSSH, allowing only scp and/or
          : sftp
[root@localhost ovidiu]# 
you don’t need to run as in debian apt-get update as yum will take care of this automatically

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=/
$basearch&repo=os
#baseurl=http://mirror.centos.org/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
#released updates
[updates]
name=CentOS-$releasever - Updates
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=/
$basearch&repo=updates
#baseurl=http://mirror.centos.org/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=/
$basearch&repo=extras
#baseurl=http://mirror.centos.org/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=/
$basearch&repo=centosplus
#baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=/
$basearch&repo=contrib
#baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5

/etc/yum.conf

[main]
cachedir=/var/cache/yum
keepcache=0
debuglevel=2
logfile=/var/log/yum.log
distroverpkg=redhat-release
tolerant=1
exactarch=1
obsoletes=1
gpgcheck=1
plugins=1
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=16&/
ref=http://bugs.centos.org/bug_report_page.php?category=yum

# Note: yum-RHN-plugin doesn't honor this.
metadata_expire=1h

installonly_limit = 5

# PUT YOUR REPOS HERE OR IN separate files named file.repo
# in /etc/yum.repos.d

  • keepthecache = 0 = no you want it to search for the cache every time
  • a debug level is what is going to put in the logfile
  • location of the log file in /var/log/yum.log
  • if it needs to be the exact architecture
  • how tolerant it is of dependencies
  • check for obsolete files and delete them if they are obsolete
  • wether or not it uses plugins.
    • Now plugins are neat and one of them is fastestmirror that will look for the fastest mirror availble in order to get the packages quicker
Finally it also states that if you have separate repositories you either put it in this file or in a file called file.repo in /etc/yum.repos.d, it used to be that you would specify right in this conf file the repositories but now they segregated that out so now you have separate repo files and it iwll pull from all of them.

 

yumdownloader

yumdownloader just gets the rpm files
In CentOS 5.7 we need to install yum-utils package
[root@localhost ~]# yumdownloader openssh-clientsLoaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ch-center.com
 * extras: mirrors.ch-center.com
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: mirrors.ch-center.com
openssh-clients-4.3p2-82.el5.i386.rpm                | 455 kB     00:00
 [root@localhost ~]# ls
anaconda-ks.cfg  install.log         openssh-clients-4.3p2-82.el5.i386.rpm
Desktop          install.log.syslog  scsrun.log
[root@localhost ~]# 

It will go to the repository and will get the rpm package
By default yumdownloader does not resolve dependencies but:
[root@localhost ~]# yumdownloader --resolve openssh-clients
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.ch-center.com
 * extras: mirrors.ch-center.com
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: mirrors.ch-center.com
--> Running transaction check
---> Package openssh-clients.i386 0:4.3p2-82.el5 set to be updated
--> Processing Dependency: openssh = 4.3p2-82.el5 for package: openssh-clients
--> Running transaction check
---> Package openssh.i386 0:4.3p2-82.el5 set to be updated
--> Finished Dependency Resolution
openssh-clients-4.3p2-82.el5.i386.rpm                | 455 kB     00:00     
openssh-4.3p2-82.el5.i386.rpm                        | 291 kB     00:00     
[root@localhost ~]# 

It’s a neat way to get the latest packages

yum can do pretty much as apt can

RPM

- not for just installing packages

- does not care for dependencies

It can  
install installs rpm package, no deps check
remove remove rpm package
check signature makes sure that it’s a valid package, sigend with a proper gpg sig
verify see if everything is there and has not been tampered with
queries query for a package

Install an RPM package: ( -i )

[root@localhost ~]# rpm -i openssh-clients-4.3p2-82.el5.i386.rpm 
error: Failed dependencies:
openssh = 4.3p2-82.el5 is needed by openssh-clients-4.3p2-82.el5.i386
[root@localhost ~]#

RPM does not install dependencies automatically so we have to:

[root@localhost ~]# rpm -i openssh-4.3p2-82.el5.i386.rpm 
[root@localhost ~]#

As we can see it installed it fine and now we can do the ssh-clients

[root@localhost ~]# rpm -i openssh-clients-4.3p2-82.el5.i386.rpm 
[root@localhost ~]#

Erase an RPM Package ( -e )

[root@localhost ~]# rpm -e openssh
error: Failed dependencies:
openssh = 4.3p2-82.el5 is needed by (installed) openssh-clients-4.3p2-82.el5.i386
[root@localhost ~]#

again it says you can’t do that because openssh-clients depends on it

to fix this first uninstall openssh-clients

[root@localhost ~]# rpm -e openssh-clients
[root@localhost ~]# rpm -e openssh
[root@localhost ~]#

Force install packages via RPM ( --nodeps)

If we:

[root@localhost ~]# rpm -i openssh-clients-4.3p2-82.el5.i386.rpm 
error: Failed dependencies:
openssh = 4.3p2-82.el5 is needed by openssh-clients-4.3p2-82.el5.i386
[root@localhost ~]#

do this it will not let us, but:

[root@localhost ~]# rpm -i --nodeps openssh-clients-4.3p2-82.el5.i386.rpm 
[root@localhost ~]#

It will let you install the package but it’s broken as it can not be used.

[root@localhost ~]# rpm -e openssh-clients
[root@localhost ~]#

Making sure you are dealing with original packages ( -K)

[root@localhost ~]# rpm -K openssh-clients-4.3p2-82.el5.i386.rpm 
openssh-clients-4.3p2-82.el5.i386.rpm: (sha1) dsa sha1 md5 gpg OK
[root@localhost ~]#

Verobse flag ( -v)

[root@localhost ~]# rpm -iv *.rpm
Preparing packages for installation...
openssh-4.3p2-82.el5
openssh-clients-4.3p2-82.el5
[root@localhost ~]#

Verify and verbose ( -Vv )

[root@localhost ~]# rpm -Vv openssh
........ /etc/ssh
........ c /etc/ssh/moduli
........ /usr/bin/ssh-keygen
........ /usr/libexec/openssh
........ /usr/libexec/openssh/ssh-keysign
........ /usr/share/doc/openssh-4.3p2
........ d /usr/share/doc/openssh-4.3p2/CREDITS
........ d /usr/share/doc/openssh-4.3p2/ChangeLog
........ d /usr/share/doc/openssh-4.3p2/INSTALL
........ d /usr/share/doc/openssh-4.3p2/LICENCE
........ d /usr/share/doc/openssh-4.3p2/OVERVIEW
........ d /usr/share/doc/openssh-4.3p2/README
........ d /usr/share/doc/openssh-4.3p2/README.dns
........ d /usr/share/doc/openssh-4.3p2/README.nss
........ d /usr/share/doc/openssh-4.3p2/README.platform
........ d /usr/share/doc/openssh-4.3p2/README.privsep
........ d /usr/share/doc/openssh-4.3p2/README.smartcard
........ d /usr/share/doc/openssh-4.3p2/README.tun
........ d /usr/share/doc/openssh-4.3p2/RFC.nroff
........ d /usr/share/doc/openssh-4.3p2/TODO
........ d /usr/share/doc/openssh-4.3p2/WARNING.RNG
........ d /usr/share/man/man1/ssh-keygen.1.gz
........ d /usr/share/man/man8/ssh-keysign.8.gz
[root@localhost ~]#
[root@localhost ~]# rpm -Vv openssh-clients
........ c /etc/ssh/ssh_config
........ /usr/bin/.ssh.hmac
........ /usr/bin/scp
........ /usr/bin/sftp
........ /usr/bin/slogin
........ /usr/bin/ssh
........ /usr/bin/ssh-add
........ /usr/bin/ssh-agent
........ /usr/bin/ssh-copy-id
........ /usr/bin/ssh-keyscan
........ d /usr/share/man/man1/scp.1.gz
........ d /usr/share/man/man1/sftp.1.gz
........ d /usr/share/man/man1/slogin.1.gz
........ d /usr/share/man/man1/ssh-add.1.gz
........ d /usr/share/man/man1/ssh-agent.1.gz
........ d /usr/share/man/man1/ssh-copy-id.1.gz
........ d /usr/share/man/man1/ssh-keyscan.1.gz
........ d /usr/share/man/man1/ssh.1.gz
........ d /usr/share/man/man5/ssh_config.5.gz
[root@localhost ~]#
[root@localhost ~]# rpm -Vv openssh-clients
S.5....T  c /etc/ssh/ssh_config
........    /usr/bin/.ssh.hmac
........    /usr/bin/scp
........    /usr/bin/sftp
........    /usr/bin/slogin
........    /usr/bin/ssh
........    /usr/bin/ssh-add
........    /usr/bin/ssh-agent
........    /usr/bin/ssh-copy-id
........    /usr/bin/ssh-keyscan
........  d /usr/share/man/man1/scp.1.gz
........  d /usr/share/man/man1/sftp.1.gz
........  d /usr/share/man/man1/slogin.1.gz
........  d /usr/share/man/man1/ssh-add.1.gz
........  d /usr/share/man/man1/ssh-agent.1.gz
........  d /usr/share/man/man1/ssh-copy-id.1.gz
........  d /usr/share/man/man1/ssh-keyscan.1.gz
........  d /usr/share/man/man1/ssh.1.gz
........  d /usr/share/man/man5/ssh_config.5.gz

S = it changed in filesize
5 = MD5 signature changed
T = modification time is changes from the original installed package

Query ( -q, -qi, -qd, -qa )

  • q = query
  • qi = query information
  • qd = query documentation
  • qa = query all
[root@localhost ~]# rpm -q openssh
openssh-4.3p2-82.el5
[root@localhost ~]# rpm -qi openssh
Name : openssh Relocations: (not relocatable)
Version : 4.3p2 Vendor: CentOS
Release : 82.el5 Build Date: Wed 22 Feb 2012 06:05:09 PM EET
Install Date: Mon 12 Ian 2009 06:18:51 PM EET Build Host: builder10.centos.org
Group : Applications/Internet Source RPM: openssh-4.3p2-82.el5.src.rpm
Size : 747178 License: BSD
Signature : DSA/SHA1, Wed 22 Feb 2012 08:46:31 PM EET, Key ID a8a447dce8562897
URL : http://www.openssh.com/portable.html
Summary : The OpenSSH implementation of SSH protocol versions 1 and 2
Description :
SSH (Secure SHell) is a program for logging into and executing
commands on a remote machine. SSH is intended to replace rlogin and
rsh, and to provide secure encrypted communications between two
untrusted hosts over an insecure network. X11 connections and
arbitrary TCP/IP ports can also be forwarded over the secure channel.

OpenSSH is OpenBSD's version of the last free version of SSH, bringing
it up to date in terms of security and features, as well as removing
all patented algorithms to separate libraries.

This package includes the core files necessary for both the OpenSSH
client and server. To make this package useful, you should also
install openssh-clients, openssh-server, or both.
[root@localhost ~]#
[root@localhost ~]# rpm -qd openssh
/usr/share/doc/openssh-4.3p2/CREDITS
/usr/share/doc/openssh-4.3p2/ChangeLog
/usr/share/doc/openssh-4.3p2/INSTALL
/usr/share/doc/openssh-4.3p2/LICENCE
/usr/share/doc/openssh-4.3p2/OVERVIEW
/usr/share/doc/openssh-4.3p2/README
/usr/share/doc/openssh-4.3p2/README.dns
/usr/share/doc/openssh-4.3p2/README.nss
/usr/share/doc/openssh-4.3p2/README.platform
/usr/share/doc/openssh-4.3p2/README.privsep
/usr/share/doc/openssh-4.3p2/README.smartcard
/usr/share/doc/openssh-4.3p2/README.tun
/usr/share/doc/openssh-4.3p2/RFC.nroff
/usr/share/doc/openssh-4.3p2/TODO
/usr/share/doc/openssh-4.3p2/WARNING.RNG
/usr/share/man/man1/ssh-keygen.1.gz
/usr/share/man/man8/ssh-keysign.8.gz
[root@localhost ~]#

 
[root@localhost ~]# rpm -qa | grep glibc
glibc-2.5-65.el5_7.3
glibc-common-2.5-65.el5_7.3
[root@localhost ~]#

Does not do dependency resolution

rpm2cpio

it’s  a binary representation of the files that are inside the rpm

[root@localhost ~]# rpm2cpio openssh-4.3p2-82.el5.i386.rpm > stuff.cpio
-rw-r--r-- 1 root root 750696 Mar 12 03:31 stuff.cpio
[root@localhost ~]# less stuff.cpio
drwxr-xr-x 2 root root 0 Feb 22 18:05 ./etc/ssh
-rw------- 1 root root 132839 Feb 22 18:05 ./etc/ssh/moduli
-rwxr-xr-x 1 root root 129488 Feb 22 18:05 ./usr/bin/ssh-keygen
[…]
[root@localhost ~]# cpio -ivd < stuff.cpio 
./etc/ssh
./etc/ssh/moduli
./usr/bin/ssh-keygen
./usr/libexec/openssh
./usr/libexec/openssh/ssh-keysign
./usr/share/doc/openssh-4.3p2
./usr/share/doc/openssh-4.3p2/CREDITS
./usr/share/doc/openssh-4.3p2/ChangeLog
./usr/share/doc/openssh-4.3p2/INSTALL
./usr/share/doc/openssh-4.3p2/LICENCE
./usr/share/doc/openssh-4.3p2/OVERVIEW
./usr/share/doc/openssh-4.3p2/README
./usr/share/doc/openssh-4.3p2/README.dns
./usr/share/doc/openssh-4.3p2/README.nss
./usr/share/doc/openssh-4.3p2/README.platform
./usr/share/doc/openssh-4.3p2/README.privsep
./usr/share/doc/openssh-4.3p2/README.smartcard
./usr/share/doc/openssh-4.3p2/README.tun
./usr/share/doc/openssh-4.3p2/RFC.nroff
./usr/share/doc/openssh-4.3p2/TODO
./usr/share/doc/openssh-4.3p2/WARNING.RNG
./usr/share/man/man1/ssh-keygen.1.gz
./usr/share/man/man8/ssh-keysign.8.gz
1467 blocks
[root@localhost ~]# ls
anaconda-ks.cfg install.log openssh-clients-4.3p2-82.el5.i386.rpm usr
Desktop install.log.syslog scsrun.log
etc openssh-4.3p2-82.el5.i386.rpm stuff.cpio
[root@localhost ~]#

No comments:

Post a Comment