Linux HOWTOs

About | Home | Search


HOWTO: libssh
Description: SSHv1 and SSHv2 client/server library
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# libssh 0.6.3
# ============
# This should not be confused with libssh2

# Slackware 14.0: libssh 0.5.2
# Slackware 14.1: libssh 0.5.4

# Prerequisites:
# CMake >= 2.6.0
# OpenSSL >= 0.9.8 or libgcrypt >= 1.4
# zlib >= 1.2 (optional)
# doxygen (optional)
# pkg-config

# Get it
cd
test -f installed/libssh-0.6.3.tar.xz &&
 mv -f installed/libssh-0.6.3.tar.xz .
test ! -f libssh-0.6.3.tar.xz &&
 wget --no-check-certificate https://red.libssh.org/attachments/download/\
87/libssh-0.6.3.tar.xz

# Verify tarball w/ md5sum:
echo "66cf16e77f60913b4d54f18c92cdbf71  libssh-0.6.3.tar.xz" | md5sum -c

# Verify tarball w/ GnuPG:
( gpg --list-keys CC014E3D 2> /dev/null || gpg --recv-keys CC014E3D ) &&
 wget --no-check-certificate -nc https://red.libssh.org/attachments/\
download/86/libssh-0.6.3.tar.asc &&
  ( xzcat libssh-0.6.3.tar.xz | gpg --verify libssh-0.6.3.tar.asc - ) &&
   rm libssh-0.6.3.tar.asc

# Extract the source
mkdir -p -0700 src
cd src
find -maxdepth 1 -type d -name "libssh-*" -exec rm -r {} \;
tar xJvf ~/libssh-0.6.3.tar.xz
cd libssh-0.6.3
test $UID = 0 && chown -R root:root .

# Create a build directory
mkdir build
cd build

# As run below, it did find my 64-bit OpenSSL installed from source under
# the default prefix of /usr/local/ssl with libraries in
# /usr/local/ssl/lib64 (it uses pkgconfig to find it)

# Configure the build with CMake
# The -D defines override settings in ../DefineOptions.cmake
# To see what settings it is using after running cmake, look at
#  CMakeCache.txt

# 64-bit Linux:
test $(uname -m) = "x86_64" &&
 cmake -DCMAKE_INSTALL_PREFIX=/usr -DWITH_SSH1=ON\
 -DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include\
 -DLIB_INSTALL_DIR=/usr/lib64 ..

# Anything else:
test $(uname -m) != "x86_64" &&
 cmake -DCMAKE_INSTALL_PREFIX=/usr -DWITH_SSH1=ON\
 -DOPENSSL_INCLUDE_DIR=/usr/local/ssl/include ..

# Build it
make

# Become root to install it
su

# Remove the Slackware package, if there is one
test -x /sbin/removepkg && /sbin/removepkg libssh

# Install it
make install
ldconfig

# Remove old ones, then install docs where Slackware usually does
find /usr/doc -maxdepth 1 -type d -name "libssh-*" \
 -exec rm -r {} \;
mkdir /usr/doc/libssh-0.6.3
cd ..
cp -p AUTHORS BSD COPYING ChangeLog INSTALL README /usr/doc/libssh-0.6.3/
chown -R root:root /usr/doc/libssh-0.6.3

# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .

# Become your non-root user again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/libssh-0.6.3.tar.xz
mv libssh-0.6.3.tar.xz installed/


# If you ever want to uninstall libssh, this should do it:
cd
su
find /usr/doc -maxdepth 1 -type d -name "libssh-*" -exec rm -r {} \;
test -d /usr/include/libssh && rm -r /usr/include/libssh
test -d /usr/lib/cmake &&
 ( cd /usr/lib/cmake
   rm -f libssh-config.cmake libssh-config-version.cmake )
test -d /usr/lib/pkgconfig &&
 ( cd /usr/lib/pkgconfig
   rm -f libssh.pc libssh_threads.pc )
test -d /usr/lib64/cmake &&
 ( cd /usr/lib64/cmake
   rm -f libssh-config.cmake libssh-config-version.cmake )
test -d /usr/lib64/pkgconfig &&
 ( cd /usr/lib64/pkgconfig
   rm -f libssh.pc libssh_threads.pc )
find /usr/share/doc -maxdepth 1 -type d -name "libssh-*" -exec rm -r {} \;
rm -f /usr/lib/libssh.so* /usr/lib/libssh_threads.so*
test -d /usr/lib64 &&
 rm -f /usr/lib64/libssh.so* /usr/lib64/libssh_threads.so*
ldconfig
exit
find ~/src -maxdepth 1 -type d -name "libssh-*" -exec rm -r {} \;
rm -f ~/installed/libssh-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>