OpenSUSE Linux Tips, tricks, how-tos, opinions, and news
My Resume - My LinkedIn Profile - twitter: @scottmmorrisSteven Rosenberg gives Ubuntu the boot and makes a move to Fedora 12. The result? He got his Intel 830m video card to work. Nice!
At the recommendation of reader David Gurvich, as well as the enthusiastic endorsement of "Linux Outlaws" co-host Fabian A. Scherschel and Larry "the Free Software Guy" Cafiero, I burned my first Fedora disc in some time and am testing Fedora 12 in the live environment.
My latest foray into distro-hopping ā live CD/DVDs only at this point ā is prompted by this week's total fail in turning off kernel mode setting and getting the screen to work in Ubuntu Lucid Alpha 3. That method (turning off kernel mode setting) worked like so much magic in Ubuntu Lucid Alpha 2 and Sidux 2009-04 (basically Debian Sid in late 2009).
But that hack did nothing for me in Ubuntu Lucid Alpha 3. Yes, dear readers, I know you hate to hear me whine and complain and would rather I file a bug report. I will do so, using my ever-loving Launchpad account, rest assured.
But in the interim I'm looking for any and every solution that will carry my now-two working Intel 830m-equipped laptops through the next year.
I'm crossing my fingers (but have nothing concrete at present) that Debian Squeeze will accommodate Intel 830m, and I'm hopeful that Ubuntu Lucid will work this out (although a regression between alpha releases doesn't bode well).
I've also established that PC-BSD 8.0 (and by extension FreeBSD 8.0) has no problem whatsoever with Intel 830m video.
And today I burned a Fedora 12 live image and am running it right now.
Read "You know what's working on my laptop with Intel 830m video? Fedora 12, that's what"
Being a musician and a Linux user myself, this one certainly caught my attention! I use Muse along with my Roland Fantom X-8 to write and play music on Linux. Some of these tools look slick.
Excerpt:
A loop in music is a section of the music that repeats itself continuously until receiving a signal to either stop or move on to the next section. A loop can be assigned to a single instrument or to a group of instruments. Compositionally, loops are used for a variety of purposes. For example, they may function as formal bass patterns over which a composition is built, or they may suppy a long but consistently repeating series of chords used to define the harmony for independently composed bass and melody lines. For many computer-based music-makers the loop's most popular implementation is the drum loop, a rhythmic pattern of one or more measures of percussion sounds that can be repeated unchanged for simple lines or mixed & matched with other loops for more life-like variation.
Read the rest of "Getting Loopy: Performance Loopers For Linux Musicians"
Linux has a tendency to lessen the following problem. Have you ever seen a zombie Linux box? Let alone 12 Million of them.
northernboy and many other readers sent news of the beheading of the Mariposa botnet with three arrests in Spain. "Defense Intelligence of Ottawa working with ISPs and Spanish authorities have taken down yet another > 12M PC botnet, called Mariposa. The three top-level operators are in custody, but remain anonymous under Spanish law (how quaint: apparently in Spain, the accused have some right to privacy). AP is claiming that the botnet included systems in roughly half of the Fortune 1000 companies, scattered over 190 countries. Interesting details: none of the three principals has a prior criminal record. Although apparently hardworking, they are not uber-hackers, but rather had connections to the Spanish mafia, which apparently helped to equip them. At the time of arrest, they were not showing signs of their significant new income level. From the article: 'Chris Davis, CEO of Ottawa-based Defence Intelligence, said he noticed the infections when they appeared on networks of some of his firm's clients, including pharmaceutical companies and banks. It wasn't until several months later that he realized the infections were part of something much bigger. After seeing that some of the servers used to control computers in the botnet were located in Spain, Davis and researchers from the Georgia Tech Information Security Center joined with software firm Panda Security, which is headquartered in Bilbao, Spain. The investigators caught a few lucky breaks. For one, the suspects used Internet services that wound up cooperating with investigators. That isn't always the case.'"
Read more of this story at Slashdot.

Ophcrack is the Linux LiveCD that you reach for when you forget your admin password on your Win32 (incl. XP and Vista) box.
From the Ophcrack Sourceforge page:
“Ophcrack is a Windows password cracker based on a time-memory trade-off using rainbow tables. This is a new variant of Hellman’s original trade-off, with better performance. It recovers 99.9% of alphanumeric passwords in seconds.”
For all admins who use said proprietary OS, if you ever forget your admin password, this is one great way to recover it, and help you keep your job.
Please do not ever, ever, ever use tools like this for malicious purposes, because that’s just plain not very nice.
As many know, one of my BIGGEST gripes with Gnome and/or GTK-based apps is their inability to NATIVELY support remote filesystem access, like Konqueror does by default, and Kate does by default, and many of the other applications built for KDE do by default. As mentioned in a previous post:
“kio-slave – For anyone who doesn’t know what this does, it gives KDE the ability to interact with remote filesystems via FTP, SSH, etc. You can open up a remote filesystem, and drag and drop a text file right onto your Kate icon. Kate will open the file for you to edit it. When you are done editing, just click SAVE and close the file. KDE via kio-slave saves the file back to the remote fileystem (assuming you have the proper privileges). This is the one thing that has the supremest of importance to me. It is possible to have one Konqueror window open and have it split into 16 different panes, each pane connected to a different filesystem or directory, whether local or remote. If you have never done this, you have to try it some time. You can split Kate windows the same way. Before anyone says it, I realize that you can make other desktop environments do this, but KDE just does it right out of the box.”
Some may even remember when I posted a bit of a rant about this. I use remote filesystems ALL DAY LONG.
As I’m moving away from KDE and everything that ties me to it, the need arose to access remote filesystems very quickly in a windowing system. I realize ssh does this. With ssh, it takes about 12 seconds to log in and copy a file over, not to mention all the keystrokes. With Konqueror, I click the Konqueror Icon, press CTRL+SHIFT+L, and select the remote filesystem I want from my bookmarks and I’m there. All of 3 seconds and a tenth of the effort.
How to mimic the functionality I want?
One possibility is a little app called gigolo. Why the name? As the author says, “Because it mounts what its told to.”
For XFCE4 users, this little baby is pretty fun. It allows you to bookmark remote filesystems, autoconnect to them, and all sorts of great stuff, quite a bit like kio-slave does. Just a bit more cumbersome, but at least I get the functionality.
Experience is a great teacher, so add the repo and install gigolo:
[1207][root@suse-desktop:/home/scott]$ zypper addrepo "http://download.opensuse.org/repositories/X11:/xfce/openSUSE_11.1" XFCE4 ; zypper modifyrepo -r XFCE4 ; zypper in gigolo Adding repository 'XFCE4' [done] Repository 'XFCE4' successfully added Enabled: Yes Autorefresh: No URI: http://download.opensuse.org/repositories/X11:/xfce/openSUSE_11.1 Autorefresh has been enabled for repository 'XFCE4'. Retrieving repository 'XFCE4' metadata [done] Building repository 'XFCE4' cache [done] Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW package is going to be installed: gigolo Overall download size: 90.0 K. After the operation, additional 310.0 K will be used. Continue? [YES/no]: Retrieving package gigolo-0.3.2-1.1.i586 (1/1), 90.0 K (310.0 K unpacked) Retrieving: gigolo-0.3.2-1.1.i586.rpm [done] Installing: gigolo-0.3.2-1.1 [done] [1208][root@suse-desktop:/home/scott]$
Now just run it. You’ll get a window similar to the following:

Press CTRL+B to edit your bookmarks. A window like this comes up:

Click ADD. In the box that appears, fill out the info and click OK:

If you selected autoconnect, you’ll be prompted for the password:

You may also have to create a keyring password. When you are done, if you selected autoconnect, you’ll see an icon showing that it’s connected:

If not, click the down arrow next to the bookmark button (furthest left), and select the bookmark you want to connect to:

Once you have connected to a bookmark, double-click it in the gigolo window. Nautilus comes up displaying the remote filesystem. Not sure if you can use other file managers, but if you can, let me know.
In the search for a full weight loss program for my window manager (I’m switching from KDE 3.5 to XFCE4), it became clear that another terminal would have to replace Konsole. After 11 full minutes of considerable thought, agonizing contemplation, deliberation and extensive research, aterm became the obvious choice.
aterm looked interesting to me because it has a small memory footprint. Konqueror takes up about 7 times the RAM that aterm does, while xterm takes over twice the RAM that aterm does. aterm also has very little dependencies. Additionally, it supports pseudo-transparencies, while remaining very responsive and quick.
The first thing you want to do is install aterm. This does not appear to be available on OpenSUSE 11.1 by default. But just add the following repo:
http://download.opensuse.org/repositories/home:/-miska-:/Release/openSUSE_11.1
Add the repo as root like this:
[1049][root@laptop:~]$ zypper addrepo http://download.opensuse.org/repositories/home:/-miska-:/Release/openSUSE_11.1 aterm Adding repository 'aterm' [done] Repository 'aterm' successfully added Enabled: Yes Autorefresh: No URI: http://download.opensuse.org/repositories/home:/-miska-:/Release/openSUSE_11.1 [1049][root@laptop:~]$
Refresh the repo:
[1049][root@laptop:~]$ zypper refresh aterm Retrieving repository 'aterm' metadata [done] Building repository 'aterm' cache [done] Specified repositories have been refreshed. [1050][root@laptop:~]$
Install aterm:
[1112][root@dev:/home/scott]$ zypper install aterm Loading repository data... Reading installed packages... Resolving package dependencies... The following NEW package is going to be installed: AfterStep_applets_all Overall download size: 310.0 K. After the operation, additional 1.1 M will be used. Continue? [YES/no]: Retrieving package AfterStep_applets_all-070412-5.13.x86_64 (1/1), 310.0 K (1.1 M unpacked) Retrieving: AfterStep_applets_all-070412-5.13.x86_64.rpm [done] Installing: AfterStep_applets_all-070412-5.13 [done] [1112][root@dev:/home/scott]$
Now, run aterm in a terminal window or something to make sure it’s installed.
On to the configuration (which is the cool part, really).
First, determine which font you want to use by running xfontsel. It opens up a window where you can fine-tune the font you want aterm to use.
Then, you’ll want to set up your configuration file. I use .Xresources although there are others you can use.
Copy and paste this into your .Xresources file, and then adjust as necessary:
aterm*font: -*-fixed-medium-r-*-*-18-*-*-*-*-*-iso8859-* aterm*font1: -*-*-*-*-*-*-2-*-*-*-*-*-*-* aterm*font2: -misc-fixed-*-r-normal-*-8-*-*-*-*-*-iso8859-* aterm*font3: -b&h-lucidatypewriter-bold-*-*-*-12-*-*-*-*-*-*-* aterm*font4: -*-screen-bold-r-normal-*-16-*-*-*-*-*-iso8859-* aterm*font5: -*-lucidatypewriter-medium-*-*-*-18-*-*-*-*-*-*-* aterm*font6: -*-lucidatypewriter-medium-*-*-*-20-*-*-*-*-*-*-* aterm*font7: -dec-terminal-bold-r-normal-*-14-*-*-*-*-*-iso8859-* aterm*background: black aterm*foreground: white aterm*pointerColor: red aterm*pointerColorBackground: black aterm*cursorColor: blue aterm*internalBorder: 3 aterm*loginShell: true ! Do you want a scrollbar? aterm*scrollBar: true aterm*scrollKey: true ! How many lines do you want to save in the buffer? aterm*saveLines: 32767 aterm*multiClickTime: 250 ! Do you want transparency? aterm*transparent: true ! Do you want transparency in the scrollbar? aterm*transpscrollbar: true ! How much transparency do you want (in percent)? aterm*shading:20 !aterm*tintingType: true !aterm*tinting: #a07040 ! How many characters wide and tall should your window be? aterm*geometry: 80x40 ! Do you want a visual bell rather than an audio bell? aterm*visualBell: true
Hopefully, it’s apparent that you can use exclamation points for comments.
Everything in this sample .Xresources config file should be fairly self-explanatory.
aterm takes many of the same configuration directives as xterm. So if you see an xterm directive you want aterm to use, throw it in the .Xresources file and reload it. You reload the .Xresources file with the following command:
[1058][scott@dev:~]$ xrdb -merge .Xresources [1058][scott@dev:~]$
If you are running that command in an open aterm window, you will have to close the window and re-run aterm.
aterm is very quick and responsive, looks nice, and doesn’t take up too much memory. Take a look at it, play around with it, and enjoy it.
When you are forwarding ports through a tunnel, either locally or remotely (i.e., with the -L or -R switches), you can modify the session real-time. The way that you do this is after you start the session, you press SHIFT + ` + c (The ` key also has a ~ in it, which is the actual keypress sent to the session). If it doesn’t work the first time, press ENTER a couple of times and try it again. Once you get the “ssh>” prompt, type “?” for the commands you can put in. Here’s an example session:
[0908][scott@dev:~]$ ssh -R 8080:suseblog.com:8080 scott@suseblog.com
Password:
Last login: Thu Oct 15 11:59:43 2009 from 67.214.232.162
Have a lot of fun...
[1109][scott@mail:~]$ [PRESS SHIFT + ` + c HERE]
ssh> ?
Commands:
-L[bind_address:]port:host:hostport Request local forward
-R[bind_address:]port:host:hostport Request remote forward
-KR[bind_address:]port Cancel remote forward
[PRESS ENTER HERE]
[1110][scott@mail:~]$ [PRESS SHIFT + ` + c HERE]
ssh> -R8080:letslearnlinux.com:1080
Forwarding port.
[1110][scott@mail:~]$
OpenSSH has got to be one of the freakin’ sweetest tools *EVAR*. Anyway, enjoy!

If you have difficulty browsing on your Linux workstation at work, say, because of filters and such, this will make your day. One other thing is that you need a Linux server that is outside your network at work. Once you have this, you can use ssh to create a socks proxy. Even as an un-privileged user, type in this command:
ssh -D 8080 <username>@<host>
Replace <username> with your username and <host> with your remote Linux server host name. Once that’s successful, pop open Firefox. Go to the EDIT Menu => Preferences. Select the ADVANCED button, then go to the “Network” tab. Click the “Settings” button. Select the “Manual Proxy Configuration” radio button. In the SOCKS Host, put in either the IP or the domain name of your remote Linux box. In the port, put in 8080, as that’s the one we used.
Click “OK” and close everything (except firefox). You should now be able to browse wherever your little heart desires.
One thing to note. NS queries are NOT proxied. So if your admins are looking at the name server lookup requests, you could still get nailed. Anyway, pretty neat little thing to know about ssh. Not sure that I’ve ever seen this capability on a Win32 platform. Yet another one of the many reasons that I really enjoy Linux.
Have a totally spectacular weekend.
When you have the level of paranoia that I do, being able to generate ultra-secure passwords is a very nice thing.
My bash prompt is also something I take great pride in. Not only that, I really like it.
Well guess what, folks… you can do both with the same file. This would be your .bashrc file. Here’s a basic look at my prompt:
[1850][scott@laptop:~]$
It shows me the time, the account with which I am logged in, the hostname of the local machine, and the present working directory. All handy things to know.
Now, for the password generation thing, check this out:
[1855][scott@laptop:~]$ genpasswd 64
(#b-p>yi>ojSw@oS6PN,uo_A`;.}DuyfG{levk[Q$UgfrmAkE^t|&)dZb!Nry;
[1855][scott@laptop:~]$
You can make rainbow tables ’til the end of time, and let John the Ripper go on the /etc/shadow file with that password in it, and you ain’t gonna be cracking that password.
If this is interesting to you, or you have other suggestions of a similar nature, please, let’s have ‘em.
That all said, here’s the .bashrc file that makes this prompt and password generator possible:
# /etc/skel/.bashrc:
# This file is sourced by all *interactive* bash shells on startup. This
# file *should generate no output* or it will break the scp and rcp commands.
# colors for ls, etc.
eval `dircolors -b /etc/DIR_COLORS`
alias d="ls --color"
alias ls="ls --color=auto"
alias ll="ls -al --color"
# Change the window title of X terminals
case $TERM in
xterm*|rxvt|Eterm|eterm)
PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\007"'
;;
screen)
PROMPT_COMMAND='echo -ne "\033_${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}\033\\"'
;;
esac
##uncomment the following to activate bash-completion:
#[ -f /etc/profile.d/bash-completion ] && source /etc/profile.d/bash-completion
function proml {
local BLUE="\[\033[0;34m\]"
local RED="\[\033[0;31m\]"
local LIGHT_RED="\[\033[1;31m\]"
local WHITE="\[\033[1;37m\]"
local LIGHT_GRAY="\[\033[0;37m\]"
case $TERM in
xterm*)
TITLEBAR='\[\033]0;\u@\h:\w\007\]'
;;
*)
TITLEBAR=""
;;
esac
PS1="${TITLEBAR}\
$BLUE[$RED\$(date +%H%M)$BLUE]\
$BLUE[$LIGHT_RED\u@\h:\w$BLUE]\
$WHITE\$$LIGHT_GRAY "
PS2='> '
PS4='+ '
}
proml
alias ifconfig="/sbin/ifconfig"
genpasswd() {
local l=$1
[ "$l" == "" ] && l=20
tr -dc A-Za-z0-9\-_~\!@#$%^\&*\(\)\\\`\+\[\{\]\}\|\;:\",\<.\>/?\= < /dev/urandom | head -c ${l} | xargs
}
Hope that's as useful for you as it has been for me.
I don’t like it when people try and hack my web servers. To make myself aware of people trying to access my ssh daemon, I wrote me a little script. Yup, I’m certainly aware of DenyHosts. Notwithstanding, in the hopes that this script may find use elsewhere, I post it here. Behold, enjoy, and chuckle a bit at how much better you could write it. Then, let me know how you’d improve it:
#!/bin/sh LOGFILE=/root/hack_attempts IFS=$'\n' PATTERN="^"`date --date="1 minute ago" "+%b %e %H:%M:"`"" tail -n 1000 /var/log/messages | grep ""$PATTERN"" | grep sshd | grep -i "invalid user" | grep " from " > "$LOGFILE" if [ $(stat -c%s "$LOGFILE") -gt 0 ] ; then echo "See the attached log for details" | mailx -a "$LOGFILE" -s "Possible hack attempt" YOUREMAIL@YOURDOMAIN.COM fi rm "$LOGFILE"
Copy it to your /root folder. Name it something cool like ’ssh_foghorn’, and chmod +x it to make it executable. Put it in your /etc/crontab file to run once every minute. Make sure you set the system log to whatever your distro uses. And change the email address to your own. Doesn’t cure cancer, but for 8 lines of code, it does what it needs to.
Again, I’m sure there are better ways to do this, so let’s hear ‘em!
Reset Forgotten MySQL Root Password
Have you ever forgotten the root password on one of your MySQL servers? No? Well maybe Iām not as perfect as you. This is a quick h00tow (how to) reset your MySQL root password. It does require root access on your server. If you have forgotten that password wait for another article. Original article posted on reset mysql root password.
First things first. Log in as root and stop the mysql daemon. Now lets start up the mysql daemon and skip the grant tables which store the passwords.
mysqld_safe –skip-grant-tables
You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password.
mysql –user=root mysql
update user set Password=PASSWORD(‘new-password’) where user=’root’;
flush privileges;
exit;
Now kill your running mysqld, then restart it normally. You should be good to go. Try not to forget your password again.
Originally written Jun 2, 2008, and updated on May 21, 2009
At some point or another, you’ll likely end up needing an SSL certificate for a Web site somewhere along the line. For a commercial site, your hosting provider can or will help you get this all squared away. This article is not for people in that situation.
What we’re doing here will be to create our own Certificate Authority. Then, we’ll create our own server key and a signing request. Then, we’ll sign our own certificate using the key and certificate from our own Certificate Authority. In other words, we’re not just going to create an SSL certificate, but we’re going to sign that bad boy, too.
This is useful for personal websites that need a little security, or when you’re waiting for your real cert from a real Certificate Authority. Perhaps you need it for transmitting data from an external server to your Intranet. Or perhaps you need it in any of the three hundred thousand seven hundred forty-two other situations that may arise.
The first thing that you’ll need is root access to the server. SSH in and head somewhere secure like /root.
Next, we’ll go ahead and generate our own Certificate Authority key. In this step, we are impersonating someone like Verisign or Thawte. Well, not impersonating, but we are going to do the same thing for ourselves that they would normally do.
To create our key, we’ll run this command:
openssl genrsa -des3 -out ca.key 4096
When we do that, it looks something like this:
[1257][root@mail:~/cert]$ openssl genrsa -des3 -out ca.key 4096 Generating RSA private key, 4096 bit long modulus ...............................................................................................................................++ .................................................++ e is 65537 (0x10001) Enter pass phrase for ca.key: [enter a pass phrase here for the CA key] Verifying - Enter pass phrase for ca.key: [verify the same pass phrase here] [1258][root@mail:~/cert]$
Note that those pass phrases are something you make up right then. You are not authenticating anything, but rather setting up a pass phrase for authenticating later.
Next, we’ll need to use that key to create a certificate. Before we do this, the information that you will enter here is NOT the information you will enter later for your own server. Remember, we are emulating a Certificate Authority here. When we generate our server certificate, we will put in the real information which must differ from what is here. With that, let’s whip out the certificate. Notice that we are making it good for 3650 days, or 10 years. Adjust to your taste. So let’s make the cert, now. This is done with the following command:
openssl req -new -x509 -days 3650 -key ca.key -out ca.crt
And doing this may resemble something like this:
[1306][root@mail:~/cert]$ openssl req -new -x509 -days 3650 -key ca.key -out ca.crt Enter pass phrase for ca.key: [enter the CA pass phrase from above here] You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:WA Locality Name (eg, city) []:Redmond Organization Name (eg, company) [Internet Widgits Pty Ltd]:Microsoft Corporation Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:www.microsoft.com Email Address []:bill.gates@microsoft.com [1307][root@mail:~/cert]$
Next up on the list is to create a key that corresponds to our server. The first one we made was for the Certificate Authority. This one will be generated by and for our own server. We will do that with this command:
openssl genrsa -des3 -out server.key 4096
The output should look familiar:
[1310][root@mail:~/cert]$ openssl genrsa -des3 -out server.key 4096 Generating RSA private key, 4096 bit long modulus ................................++ ....++ e is 65537 (0x10001) Enter pass phrase for server.key: [enter a pass phrase here for our server key] Verifying - Enter pass phrase for server.key: [verify the same pass phrase here] [1313][root@mail:~/cert]$
Again, those pass phrases are something you make up right then. You are not authenticating anything, but rather setting up a pass phrase for authenticating later.
Now… let’s see… oh yeah. Now, we have to create a signing request, or CSR, from the server key we just made. This signing request will usually make a trip to a genuine Certificate Authority to have the key signed and a real, verified, bonafide signed certificate returned back to us. So, to generate our signed certificate, we’ll need to first have a signing request so we can make the signed cert. See how that works?
To create the CSR, we do this:
openssl req -new -key server.key -out server.csr
Now remember, kids. This is the part where we do put in our actual real information because the server does in fact belong to us. Put in the real domain where it says “Common Name (eg, YOUR name) []:”. Fill out everything correctly. And so we do:
[1313][root@mail:~/cert]$ openssl req -new -key server.key -out server.csr Enter pass phrase for server.key: [enter the pass phrase here for our server key from above] You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:UT Locality Name (eg, city) []:Eagle Mountain Organization Name (eg, company) [Internet Widgits Pty Ltd]:Suse Blog Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:www.suseblog.com Email Address []:my-address@suseblog.com [put in your real email address here] Please enter the following 'extra' attributes to be sent with your certificate request A challenge password []: An optional company name []: [1323][root@mail:~/cert]$
Now, we are going to take all these files and make them do some voodoo. We are going to sign the signing request using the Certificate Authority certificate and key that we made at the beginning. What we will get is our perfectly forged signed certificate. OK, not perfectly, because we are not a real CA. But we’ll get a pretty darn good signed cert that will work for us rather nicely.
The command we’re going to run looks like this:
openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt
And when we run it, we see something hopefully resembling this:
[1326][root@mail:~/cert]$ openssl x509 -req -days 3650 -in server.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out server.crt Signature ok subject=/C=US/ST=UT/L=Eagle Mountain/O=Suse Blog/CN=www.suseblog.com/emailAddress=my-address@suseblog.com Getting CA Private Key Enter pass phrase for ca.key: [enter the CA pass phrase from above here] [1332][root@mail:~/cert]$
Now, we have a little problem. Our server.key file will cause apache2 to prompt us for a password every time it starts. We need to fix it so that doesn’t happen. We’ll do that with these three commands:
openssl rsa -in server.key -out server.key.insecure mv server.key server.key.secure mv server.key.insecure server.key
When we run these commands, here’s our output:
[1354][root@mail:~/cert]$ openssl rsa -in server.key -out server.key.insecure Enter pass phrase for server.key: [enter the pass phrase here for our server key from above] writing RSA key [1354][root@mail:~/cert]$ mv server.key server.key.secure [1354][root@mail:~/cert]$ mv server.key.insecure server.key [1354][root@mail:~/cert]$
At this stage, you should now have a bunch of files. These, in fact:
[1354][root@mail:~/cert]$ ll total 32 drwxr-xr-x 2 root root 4096 2008-06-02 13:54 . drwx------ 10 root root 4096 2008-06-02 13:35 .. -rw-r--r-- 1 root root 2529 2008-06-02 13:07 ca.crt [CA certificate] -rw-r--r-- 1 root root 3311 2008-06-02 12:58 ca.key [CA key] -rw-r--r-- 1 root root 2049 2008-06-02 13:32 server.crt [our server certificate] -rw-r--r-- 1 root root 1748 2008-06-02 13:23 server.csr [our server signing request] -rw-r--r-- 1 root root 3243 2008-06-02 13:54 server.key [our password-less server key] -rw-r--r-- 1 root root 3311 2008-06-02 13:13 server.key.secure [our passworded server key] [1355][root@mail:~/cert]$
Just having them doesn’t get us anywhere, so let’s get them installed. First, we are going to change some permissions, because we don’t want just anyone having access to these files. To apply the appropriate permissions, run this:
chmod 0600 server.key.secure server.key server.csr server.crt
Now, here’s where things depend on the distribution that you are using. I will describe what I am doing so that if you are not on OpenSUSE, you will still be able to get this working.
In OpenSUSE, the apache2 config directory is located at /etc/apache2. Underneath that, there are a handful of directories. The three we care about are /etc/apache2/ssl.crt, /etc/apache2/ssl.csr, and /etc/apache2/ssl.key. The server.crt needs to be moved to /etc/apache2/ssl.crt. The server.csr file needs to be moved to /etc/apache2/ssl.csr. And the server.key file needs to be moved to /etc/apache2/ssl.key:
[1348][root@mail:~/cert]$ mv server.key /etc/apache2/ssl.key/server.key [1349][root@mail:~/cert]$ mv server.crt /etc/apache2/ssl.crt/server.crt [1349][root@mail:~/cert]$ mv server.csr /etc/apache2/ssl.csr/server.csr [1349][root@mail:~/cert]$
Yep, pretty complex stuff, moving files.
Now, we need to make a handful more edits to some files, and we’re just about there.
First thing is to edit /etc/sysconfig/apache2. Search through that file for the directive called APACHE_MODULES. Make sure you see ’ssl’ in there. If not, add it. Then, search through the file and find APACHE_SERVER_FLAGS. Make sure it has ‘SSL’ in it. If not, add it. Save and close the file.
You can also manage apache’s modules with the ‘a2enmod’ command. To view the list of loaded modules, run ‘a2enmod -l’.
Next, open up the config file that tells apache2 which ports to listen on. In OpenSUSE, this file is /etc/apache2/listen.conf. Rip that bad boy open. You will see the following line:
Listen 80
Add a new line for port 443, our HTTPS port, so that it looks like this:
Listen 80 Listen 443
Then, look for the following line:
NameVirtualHost *:80
Add a new line for port 443, our HTTPS port, so that it looks like this:
NameVirtualHost *:80 NameVirtualHost *:443
Save and quit.
In OpenSUSE, it’s really easy to have virtual hosts on a machine. I have like 10 on mine. One of them is my blog, www.suseblog.com. Well, to make this easy, in OpenSUSE, the virtual domain configuration files are located in /etc/apache2/vhosts.d, each with their own name. My www.suseblog.com configuration file is called suseblog.conf. To set up SSL for this virtual host, just duplicate the file and give it another name. In my case, I named it ssl-suseblog.conf.
Now, we’re going to open up that file and add like 4 lines to it. No sweat.
At the top of the file, there is a line that looks like this:
<VirtualHost *:80>
Change the port from 80 to 443, so it looks like this:
<VirtualHost *:443>
Then, go down a ways and add these lines:
SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /etc/apache2/ssl.crt/server.crt SSLCertificateKeyFile /etc/apache2/ssl.key/server.key
Save and quit on that one, too.
We can configure this thing perfectly, but if the firewall doesn’t know to let traffic through, we will not have HTTPS access to the server. Let’s check the firewall really quick to make sure.
Fire up YAST. Go to the Security & Users option on the right, and select FIREWALL from the left. If you do not have a firewall running on the machine, you can just exit now. If you do, you will need to go to ALLOWED SERVICES. In the SERVICES TO ALLOW drop-down on the right, select HTTPS Server. Then click ADD. Then click NEXT, and finally FINISH. You should now have port 443 opened for HTTPS business.
Now, let’s go ahead and restart apache and enjoy our new self-signed self-generated SSL cert on our HTTPS service:
[1426][root@mail:/etc/apache2]$ /etc/init.d/apache2 restart Syntax OK Shutting down httpd2 (waiting for all children to terminate) done Starting httpd2 (prefork) done [1427][root@mail:/etc/apache2]$
Well, we’ve concluded. Enjoy.
First, the stick should be in, but not mounted. If it is mounted, find the partition represented by your usb stick, as such:
[0959][scott@laptop:~]$ mount /dev/sda2 on / type ext3 (rw,acl,user_xattr) /proc on /proc type proc (rw) sysfs on /sys type sysfs (rw) debugfs on /sys/kernel/debug type debugfs (rw) udev on /dev type tmpfs (rw) devpts on /dev/pts type devpts (rw,mode=0620,gid=5) /dev/sda1 on /windows/C type fuseblk (rw,allow_other,blksize=4096) fusectl on /sys/fs/fuse/connections type fusectl (rw) none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw) gvfs-fuse-daemon on /home/scott/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=scott) /dev/sdc1 on /media/disk-1 type vfat (rw,nosuid,nodev,shortname=winnt,uid=1000) /dev/sdb1 on /media/disk-2 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=1024) [0959][scott@laptop:~]$
It will likely be a /dev/sdxx type device. In this case, the one I’m looking for is sdb1.
We need to unmount it as root (’su’):
laptop:/home/scott # umount /dev/sdb1 laptop:/home/scott #
Now, fdisk the usb stick, and not the partition. In other words, leave off the trailing digit:
laptop:/home/scott # fdisk /dev/sdb Command (m for help):
Press ‘p’ to view the partitions on the drive. Delete all partitions. Create a new one with ‘n’. It will be a primary partition, and it will be partition 1. Now, we need to set the filesystem type. Press ‘t’, and then if you’d like to see all the filesystem types, press ‘L’, but I’ll just tell you that NTFS is 7. Press ‘7′, and then ‘w’ to write the partition table, and exit:
Command (m for help): p
Disk /dev/sdb: 1027 MB, 1027604480 bytes
64 heads, 32 sectors/track, 980 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk identifier: 0x610fbfb2
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 980 1003504 c W95 FAT32 (LBA)
Command (m for help): d
Selected partition 1
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-980, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-980, default 980):
Using default value 980
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 7
Changed system type of partition 1 to 7 (HPFS/NTFS)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
laptop:/home/scott #
Now, we need to actually format the new partition. Include the partition number at the end. It should be 1. You will do this as root (’su’), like so:
laptop:/home/scott # mkntfs /dev/sdb1 Cluster size has been automatically set to 1024 bytes. Initializing device with zeroes: 100% - Done. Creating NTFS volume structures. mkntfs completed successfully. Have a nice day. laptop:/home/scott #
K, well, there you are. Mount it up any way you see fit, and you are all set.
Recently, Andrew wrote me an email, which I shall pass on for the benefit of all:
Hi Scott
I started off writing a serious email, but your “why Santa Can’t Exist” converted me to tears of laughter, the story above it soon gave me a reality check, poor girl.I was before I was interrupted with humour reading your blog posts on Linux, and was very impressed with the informative way that you write. We create video based tutorials and over the last 18 months we have been turning more of our resources to covering Linux based subjects. We have also been converting our videos to play in Flash as well as QuickTime, so Linux users don’t have to mess around installing 3rd party apps and invoke all kinds of trickery just to watch a simple training video.
I was wondering if you would consider offering some of our links to your visitors, I have listed the tutorials below that may be of interest:-
http://www.computer-training-software.com/opensuse.htm
http://www.computer-training-software.com/ubuntu-linux.htm
http://www.computer-training-software.com/ubuntu-server.htm
http://www.computer-training-software.com/ubuntu-certification.htm
http://www.computer-training-software.com/linux-security.htm
http://www.computer-training-software.com/lpi.htm
http://www.computer-training-software.com/lpic-2.htm
http://www.computer-training-software.com/linux.htm
Thanks, Andrew.
If you use Linux for day-to-day computing, you likely use the secure shell, or ssh. If you are like me, you may grow weary of constantly having to type in passwords to access remote machines. Or maybe you have the perfect backup system, except that it uses ssh to transfer files, and requires you to type in a password (such as rsync or rdiff-backup). There is a way to access those machines without using a password. This technique should be used with care. I’d use it only on machines that I have access to, for example. You don’t want to set up passwordless access from a public machine to your production server, in other words. Use with caution.
The principle is that you generate a public and private key on the local machine. This will be whatever machine you are connecting from. You then transfer the public key to the remote machine. Then, when you ssh into the remote machine, it uses the keys to authenticate. You don’t type in a password, it just takes you straight to the shell prompt. How do we set this up?
Log into the machine you are going to connect from. Let’s say that your account is called ‘user’ and you are going to connect from a machine called ‘desktop’. Log in as ‘user’ on the ‘desktop’ machine and pull up a shell. Run this command. The stuff in red is what you do,not what you type:
[0218][user@desktop:~]$ ssh-keygen -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/home/user/.ssh/id_dsa): [JUST PRESS ENTER HERE] Enter passphrase (empty for no passphrase): [JUST PRESS ENTER HERE] Enter same passphrase again: [JUST PRESS ENTER HERE] Your identification has been saved in /home/user/.ssh/id_dsa. Your public key has been saved in /home/user/.ssh/id_dsa.pub. The key fingerprint is: a5:25:c0:aa:fe:f3:9f:46:7a:23:e3:6e:10:ec:6f:d3 user@desktop [0218][user@desktop:~]$
Your keys are generated. On that machine, view /home/user/.ssh/id_dsa.pub. You will see something like this:
ssh-dss AAAAA3NzAC1kc3MAAACAANfnr9xkAks2u8Xd5I9nozzsXLKCYA8o9h3cMwL5QMcZGxz84Dyl3IyRwozv3I2xGwJAYyAHvJAS7AQmtFXtfmQts3dt2ZnlAmKj0TkC8pwDgvXJYzARJpCP2Zx7iwD/OCO3sTgT0wGwYtQrAcTeW5Tt6sSmQjEJ2rJj+Q5XA1xvAAAAFQDWcQ+OJRnk+jCYqESWqxHcyw74DwAAAIA9qAQyZrOJkjpzMSWAcliHvvuyCN8RInlgq+IwWynukOX7zYXcE2dJPopgpG3Aiiq/fxAQX5dUzXfSrL3KYftQOd/RNkAzMHAAzAJeQAA0wEt4uAjhGRwCOSg6wKMYJPYfVghnwIKARuSTUS8NjRXVKteHg7frOOHZwRGIm36pxgAAAIA8/CKLLn5QRctsvvvmvpOn2Xhek02z8K0YukYcXJOQ1FMTYWoHujA39sEAFsdx6Nq1t58lI2dsj6fpf7LOOvoYWtKQnTNRUptlOx27LTO9Q6DhKPV/93nLI/xFOFo/8twZ1TmpAgpAI3SQ9YCnX2A8H686OUwUPmY0kA+H8GKnug== user@desktop
What you need to do now, is determine the remote machine you are going to log into. Then, decide what user you are going to log in as on that machine. We are going to log in as a user called ‘admin’ on a server called ’server’. First, we will ssh into ’server’ as ‘admin’. Then, edit the file located at ~/.ssh/authorized_keys2. If it is not there, create it. All you need to do is paste the contents of the id_dsa.pub file from the ‘user’ account on the ‘desktop’ machine into the ~/.ssh/authorized_keys file for ‘admin’ on ’server’.
For example:
I go to my desktop, log in as ‘user’. I run ’ssh-keygen -t dsa’. It generates a ~/.ssh/id_dsa.pub file in my home directory.
I want to connect as ‘admin’ on a box called ’server’. I ssh in normally as ‘admin’ into the ’server’ machine. I edit the ~/.ssh/authorized_keys2 using my favorite text editor. I add the contents of the ~/.ssh/id_dsa.pub file from my desktop machine into the authorized_keys2 file on ’server’. I then save and quit. I then close all connections to ’server’. Then, I type ’ssh admin@server’, and hit ENTER. It drops me straight to a shell prompt.
This is a nice way to access a machine without having to type in the password every time. Only do this from machines that only you or authorized personnel have access to. Otherwise, you could have a li’l security problem.
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| « Feb | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 | |||
188 queries. 0.977 seconds