My thoughts on Slackware, life and everything

Month: February 2010

Securing remote root access

If you ever ran a SSH server on the Internet, you will probably have noticed the massive amount of ssh break-in attempts.

There are a few easy ways to get rid of the attacks and at the same time prevent your root account from being compromised.

  1. move the SSH listen port from TCP port 22 to a non-standard port
  2. disallow connections with the older and easily cracked “Protocol 1”
  3. disallow remote root logins

These countermeasures are easily taken by editing the ssh daemon’s configuration file “/etc/ssh/sshd_config“. below, I will show you the lines to lookup and the changed line which needs to take its place:

  • Move the ssh listen port from 22 to 12345. This will get rid of most break-in attempts right away because these only target the well-known port 22:

#Port 22
Port 12345

  • Disallow the use of the old “Protocol 1”

#Protocol 2,1
Protocol 2

  • Disallow the root user to logon directly

#PermitRootLogin yes
PermitRootLogin no

After these changes have been made, you will have to restart the SSH server:

# /etc/rc.d/rc.sshd restart

When you disable root logon through SSH, the only possibility to become root on this computer remotely is to logon as a normal user first, and then use “su” or “sudo” to become root.

This has negative implications if you are used to make remote backups from your server and connect to it as root… because that is the only way to be able to access and read every file in the filesystem.

When you need remote root access but still want to disable password logins for root, there is a further change you have to make to one of the lines I showed you earlier. What I will show you next is how to prevent password logins for root while still allowing entrance using a SSH key. You can protect this SSH key with a passphrase so that it is impossible for someone who steals this key to force his way in as root – he will have the SSH key in his possession, but will not know the passphrase to unlock it!

In order for this to work, the SSH server must allow Public Key Authentication for Protocol2. In Slackware this is the default anyway:

#PubkeyAuthentication yes
#AuthorizedKeysFile     .ssh/authorized_keys

Now, let’s allow root to use a SSH key for loggin in. Change the following line in “/etc/ssh/sshd_config“:

PermitRootLogin no

to

PermitRootLogin without-password

and then restart the SSH daemon again (see above).

Finally, you will have to generate a SSH key that can be used for remote logins and copy the public keyfile to your SSH server.

ssh-keygen -t rsa

You will have to answer a few questions: under which name should the new keyfile be stored, and what passphrase should be used to protect the keyfile.

Once you have generated this keyfile, copy the public key (which is the keyfile but with the “.pub” extension) to your SSH server and on that server, as user root, append it to root’s “.ssh/authorized_keys” file like this (I am using an example public key filename “your_new_sshkey.pub”):

cat your_new_sshkey.pub >> /root/.ssh/authorized_keys

In case the “authorized_keys” file did not yet exist, you will have to secure other people’s access to the file or else remote logon will still not work:

chmod 600 /root/.ssh/authorized_keys
chmod 700 /root/.ssh

Once this has been done you should now be able to logon to your SSH server as root remotely:

ssh -p 12345 -i ${HOME}/.ssh/your_new_sshkey root@remoteserver

If you want ssh to use this SSH key automatically so that all you need to type is “ssh root@remoteserver“, you should add a few lines to your “~/.ssh/config” file. Perhaps that file does not yet exist in which case you can just create it. Mind the indents, they are required:

Host remoteserver
User root
Port 12345
IdentityFile /home/your_user/.ssh/your_new_sshkey

Good luck with this!

Eric

PS: if you copy your new public key to the server before you have made any of the changes I suggested, then some of the above steps can be combined into one. The following command on your workstation will copy the public key to the SSH server, and add it to root’s “authorized_keys” file, securing that file’s access attributes if needed, all in one go:

ssh-copy-id -i ${HOME}/.ssh/your_new_sshkey root@remoteserver

Musings on Software Development With Linux

A few weeks back Laurent Parenteau asked me to contribute a post to his series “Meet the Linux family” on the blog “Software Development with Linux“. Well here it is: http://laurentparenteau.com/blog/2010/02/meet-the-linux-family-eric-hameleers/ . Nothing spectacular, but just enough controversy (I hope… I wrote “Steve Balmer” and “Eric Raymond” on the same page) to make it interesting for you to read.

Eric

Using git for version control

I have always really hated the Git Version Control System (or VCS).

I am pretty comfortable working with other products like RCS, CVS and Subversion (SVN). I am not a developer, so my main use for a VCS is a to allow me to keep track of the changes in my SlackBuild scripts or my server’s log book. I use RCS for this, it is simple but effective.

Of course, in order to compile software it is often required to check out the source code for the program. This is how I got familiar with CVS, SVN, mercurial and git. Way back when I was “build manager” for a software company, I have used PVCS, Clearcase and Visual SourceSafe which are all commercial programs. So, I have been around.

Still, git still confused me after all that time as a end-user. Git uses some alien (to me) concepts which I did not grasp because I never took the trouble to dive into its documentation – I knew just enough to checkout source code from a git repository and did not need – did not want to – know more.

This changed recently. Because two of the projects I am involved with are preparing to use git as their Version Control System, I was forced to start learning how to approach the tool as a developer.

I quickly decided it was worth the while to run two parallel tracks: start reading documentation, and at the same time actually using git by setting up a server for hosting git repositories.

I found some places which host very good reading material.

  • The Pro Git book at http://progit.org/ . This book is hosted itself in a git repository and the language translations are coordinated using git. Well-written with lots of visual examples.
  • The Git Community Book at http://book.git-scm.com/ .

I’m halfway through the “Pro Git” book, retracing my steps a few times after the new concepts found a place in my brain. Indeed, git is starting to make sense now. Surely it has some very strong points which make it interesting not only for large projects with lots of developers who are scattered all over the place (like the Linux kernel developers) but also for small projects like those I am participating in.

Perhaps I will document more about my git activities in a future Wiki article – for instance how I am setting up an online git repository.

This made me think of something else: could it be beneficial to dump the history of my SlackBuild script repository (past and future) into a git repository? What do you think – will it help you if you are able to look at older revisions of my SlackBuild scripts? Some time ago I started copying the SlackBuild script into the documentation directory of every Slackware package I create, but I realize that once I release a newer package, the older scripts disappear from public view.

Leave your opinions in the comments section below please.

Eric

Slackware ChangeLog stalling… or not?

Now that almost four weeks have passed since the last update of Slackware’s “-current ChangeLog” I am seeing posts from people who (1) start getting worried and (2) are speculating that a new stable release is imminent.

Let me re-assure you: there is a lot of behind-the-scenes work going on. Some of the updates require the recompilation and testing of other packages and this takes time to get it right.

When the time comes to push the next batch to the public, be sure that it contains a lot of goodies. Nope… no PAM in there 🙂

And equally no, this is not the runner-up to a new stable release. Due to the size of the changes, I expect that some serious user-testing is required first. Just be patient for a little longer…

Eric

It’s been released: KDE SC 4.4.0

The KDE community has announced the immediate availability of the KDE Software Compilation 4.4.0 (“KDE SC” is the new name of what used to be called just “KDE“). In preparation for this event, the kde.org website was re-vamped yesterday to reflect their “shift in marketing and promotion vocabulary”. Looks shiny and new! Also, I think that the new layout makes it easier for people to find information about the KDE community and the software compilation.

Users of small form-factor laptops will be interested to learn that the new Plasma desktop manager now offers two workspace choices. One is the usual desktop-oriented workspace. The interesting addition is a netbook-oriented workspace, with special consideration for the netbook’s smaller screen and typical mobile usage patterns. I have not yet installed KDE 4.4 on my own Asus EEE netbook but I will most certainly do so, later this week!

In order to fully appreciate the work that went into KDE SC 4.4 and learn what has changed since KDE 4.3, you should definitely take the visual tour. Lots of new functionality and usability improvements are hidden beneath this new desktop workspace and just waiting to be discovered and used to the fullest.

Slackware packages galore!

Like I did with the pre-releases of KDE 4.4, I have prepared new goodies for all you Slackers. Get those 32-bit and 64-bit packages for Slackware Linux and install them on your computers (or build them yourself using the accompanying SlackBuild scripts, patches and sources).

You will find all of those at http://alien.slackbook.org/ktown/4.4.0/ .

Please take good notice of the fact that these packages are built for Slackware-current. You can safely install the KDE 4.4.0 packages if you are running a slackware-current from around 01 february 2010 or newer. Do not try to install these packages on Slackware 13.0.

Slackware 64-bit:

  • Don’t forget to also install the updated or new dependencies! These “deps” packages can be found in the “x86_64/deps” directory.
  • The KDE 4.4.0 packages themselves can be found in “x86_64/kde
  • And of course, the localization packages (non-english language translations of KDE) are available in “x86_64/kdei“.

Slackware 32-bit:

  • Don’t forget to also install the updated or new dependencies! These “deps” packages can be found in the “x86/deps” directory.
  • The KDE 4.4.rc2 packages themselves can be found in “x86/kde
  • If you need a language pack, you can grab one from the 64-bit package tree “x86_64/kdei” since these packages are in fact architecture-independent.

Here are the steps on how you download the packages and install them. You can have an older version of KDE installed, but that is not required. You will end up with KDE 4.4.0 installed on your system.

Instructions are for the 64-bit packages, I think you can figure out how to change them if you want the 32-bit versions:

  1. Download everything in the directory http://alien.slackbook.org/ktown/4.4.0/x86_64/ :
    # lftp -c "open http://alien.slackbook.org/ktown/4.4.0/ ; mirror x86_64"
  2. Change into the directory “x86_64? which has just been created in your current directory:
    # cd x86_64
  3. Remove the no longer required kdelibs-experimental package if you still have that installed. It is part of KDE 4.3.x (i.e. Slackware 13.0 did not have this package). If you do not have kdelibs-experimental on your system, you will get a harmless error message that you can ignore:
    # removepkg kdelibs-experimental
  4. Install/upgrade the KDE 4.4 dependencies:
    # upgradepkg --reinstall --install-new deps/*.t?z
  5. Install/upgrade KDE4.4.0 packages:
  6. # upgradepkg --reinstall --install-new kde/*.t?z
  7. Install/upgrade a language package if you prefer to have the KDE interface in your local language (I used “nl” in the example command, you should substitute your own language code there):
    # upgradepkg --reinstall --install-new kdei/kde-l10n-nl-*.t?z

Of course, you should not run those commands while running KDE…!

If you want to compile the packages from source like I did, that is entirely possible using the provided sources and build scripts. It will take quite a while though…

Have fun, Eric

Note for users of any KDE 4.4 pre-releases:


If you never before installed and used one of the Betas or Release Candidates of KDE 4.4 , then you can safely remove one package,  virtuosoconverter. This package is only needed if you were using “nepomuk desktop search” before this final release of KDE 4.4.0.

# removepkg virtuosoconverter

If you ran any Beta or Release Candidate of KDE 4.4.0 prior to upgrading to 4.4.0, then you will notice that your nepomuk database will automatically be converted from virtuoso v5 to v6, the very first time you login to your KDE 4.4 desktop. This process will take a while (not too long) and will temporarily double the size of your nepomuk database (by default, this database consumes a maximum of 50 MB in your homedirectory below ~/.kde).

If this database is not valuable to you, you can also decide to skip this database conversion by just deleting the database before starting KDE:

$ rm -r ~/.kde/share/apps/nepomuk/repository/*

or by following the instructions in Sebastian Trueg’s tutorial: http://techbase.kde.org/Development/Tutorials/Metadata/Nepomuk/TipsAndTricks#Remove_all_Strigi-indexed_data

If you manually remove the old nepomuk data, you can also remove the virtuosoconverter package of course.

If you do not have any clue about what I am talking about and what you should do, just don’t do anything… and all will be well.

A final remark about nepomuk and strigi – I think that KDE 4.4 finally has a desktop search which is optimized to a level that it no longer eats all your CPU cycles or claim a large chunk of your harddrive. Now I just wish that the strigi developer properly fixes the indexing of my PDF files!

© 2025 Alien Pastures

Theme by Anders NorenUp ↑