LinuxMoz

Linux Stuff && Coffee

How to Generate / Extract a Public Key From a Private Key

| Comments

If you have lost your SSH Public key but still have your Private Key you can extract the private key with the following command:

1
2
3
lionor$ ssh-keygen -y
Enter file in which the key is (/Users/dave/.ssh/id_rsa):
Enter passphrase:

Your ssh public key will now be displayed.

the above was entered on a Mac, the same applies for Linux obviously your home drive location would be /home – I would recommend this option over opening the file and copying and pasting it out, I would then echo the input into a key file and copy it to the remote server.

How to Copy SSH Public Key From a Mac to a Linux Server

| Comments

In order to login to your Linux Server over SSH from a Mac you must first copy over your Public key and Mac OSX does not come with the ssh-copy-id command so you need to copy the public key from Mac OSX to the Linux server manually.

Copy SSH Public Key to Linux from Mac OSX

This assumes you have access to the remote server via password based authentication (typing in a password), to start with lets copy the key over.

1
scp ~/.ssh/id_rsa.pub [email protected]:/home/username/.ssh/

(Your key name may differ)  If the .ssh directory does not exist on the remote server you will need to login and create it.

Now the key has been copied from the mac to the REMOTE Linux server.

Set correct permissions for the SSH Public Key on the remote server:

1
chmod 600  ~/.ssh/id_rsa.pub

Next add the key to the SSH authorized_keys file, if the file does not exist create it.

If the file authorized_keys already exists in ~/.ssh the use the following command:

1
cat id_rsa.pub >> authorized_keys

If the file does not exist enter the following commands:

1
2
3
4
cat id_rsa.pub > authorized_keys
chmod 600 authorized_keys
chown kjs:kjs authorized_keys
vi /etc/ssh/sshd_config

You should now be able to login to the Linux server using SSH key based authentication from your Mac.

How to Setup SSH Key Authentication on Linux

| Comments

This short tutorial explains how to setup SSH to use key based authentication, by default on CentOS this is disabled. To start with follow our guide on how to generate SSH key pairs and copy the key over.

Configure SSH to enable Public Key Based Authentication

Open up /etc/sshd_config in vi and find the following lines:

1
2
#PubkeyAuthentication yes
#AuthorizedKeysFile      .ssh/authorized_keys

And un-comment them so it reads:

1
2
PubkeyAuthentication yes
AuthorizedKeysFile      .ssh/authorized_keys

Restart SSH Server with:

1
/etc/init.d/sshd restart

You should now be able to login over SSH using public key based authentication.

How to Install Wordpress on Ubuntu 12.04 LTS

| Comments

The articles explains how to install Wordpress on Ubuntu 12.04, to instructions are step by step and I use the latest version of Wordpress using the .dpkg package from apt.

To start off with install install the Ubuntu Wordpress package with:

1
apt-get install wordpress php5-gd

This should pull down and install everything you need to install Wordpress on Ubuntu, the wp files are installed into the /var/share directory you need to link them and make sure the perms are set correctly.

Create a symlink from /var/share/wordpress to /var/www/wordpress

1
sudo ln -s /usr/share/wordpress /var/www/wordpress

Create the MySQL Databases for Wordpress on Ubuntu:

1
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n wordpress localhost

**Note the -n wordpress should be replaced with the name of your database (unless you want to call it wordpress) and the domain should be changed to your real world domain e.g linuxmoz.com

Example:

1
sudo bash /usr/share/doc/wordpress/examples/setup-mysql -n linuxmoz_db linuxmoz.com

Restart Apache:

1
service apache2 restart

Set the perms for Wordpress or the install and autoupdates will not work (make sure you keep Wordpress up to date or you will get hacked).

1
chown -R www-data /usr/share/wordpress

Point your browser at https://localhost/wordpress or https://yourdomain.com/wordpress and follow the on screen instructions.

After configuration you should be good to go, make sure you update Wordpress after the installation as I suspect the package version will be out of date.

If you are using friendly URL’s then remember to enable mod_rewite on Ubuntu.

Enable Mod_rewrite on Ubuntu (Apache2)

| Comments

If your permalinks for wordpress or another CMS are not working on Ubuntu then you will need to follow this guide. To enable mod_rewrite on Ubuntu enter the following command with root permissions.

Enable mod_rewrite Ubuntu

1
sudo a2enmod rewrite

This will enable mod_rewrite for Apache2 on Ubuntu but we need to edit the default Apache2 config to AllowOverrides from .htaccess files or any rewrite rules created by various CMS’s (wordpress, drupal, etc) will be ignored.

Open the following file default apache2 config file on Ubuntu:

1
sudo vi /etc/apache2/sites-available/000-default

(Obviously you can use whatever editor you like, if you need help check out our vi commands cheat sheet.

Look for the following text “AllowOverride None” and change it to “AllowOverride All” ad restart Apache with:

1
service apache2 restart

Mod_ReWrite will now be enabled on Ubuntu systems running Apache2.

List All Installed Packages (Dpkg) on Debian

| Comments

This short tutorial shows you how to list all the installed dpkg packages on Debian (all versions). On most systems (depending on configuration) you do not need root permissions to run this command.

How to list all installed packages on Debian

On the command line enter the following command:

1
dpkg -l

This will dump all the installed packages onto the console, you might want to use less or more to limit the output.

1
dpkg -l | less

or…

1
dpkg -l | more

Alternatively if you are looking for a specific package then enter:

1
dpkg -l | grep php

The example above uses php as a package example you can replace this with any other package name apache2, awk, etc.

How to Upgrade to Ubuntu 12.04 From CD or DVD

| Comments

This tutorial explains how to upgrade to Ubuntu 12.04 using a CD or DVD – this is often the preferred method  if you have a lot of computers to upgrade or if you need to upgrade to Ubuntu 12.04 without a network or Internet connection.

The process is virtually identical to installing Ubuntu however during the process you will be given the option to upgrade depending on the version installed it will either say “Upgrade Ubuntu 10.04 to 12.04 LTS” or “Upgrade Ubuntu 11.04 to 12.04 LTS” the installer all automatically detect the version currently installed on your hard drive.

Here is an image of the upgrade option in the Ubuntu installer:

Upgrade Ubuntu 10.04 to 12.04 from CD or DVD

As mentioned above the process the same of 11.10 only the installer will say upgrade ubuntu 11.10 to ubuntu 12.04.

How To Upgrade Ubuntu 12.04 from CD or DVD Step by Step Tutorial

Below is the step by step guide for the upgrade procedure for 11.10 and LTS to LTS.

  1. Download Ubuntu 12.04 (fast direct link mirrors)

  2. Burn the ISO to CD or DVD

  3. Insert the CD or DVD into the drive and select your PC or laptop to boot from CDROM

  4. When prompted click “Install Ubuntu”

  5. Next you are give the option to “Download updates while installing” if you have a working internet connection select this method if don’t have access to the Internet un tick the box. (If in doubt un tick the box you can always install updates later). You are also given the option to install 3rd party software, leave this un ticked for now unless you have something specific you know needs installing

  6. Select “Upgrade from 11.10 to Ubuntu 12.04” (or 10.04 LTS) see the screen shot above

  7. Enter the same username and password you currently use

  8. Click Continue

  9. After the upgrade completed click “Restart Now”

Your home directory and the majority of your settings should be the same as before, if you have any issue with your 12.04 upgrade please post a comment below and I and other members of the community will do my best to help you.

How to Upgrade to Ubuntu 12.04 for Desktops & Servers Running 10.04 or 11.10

| Comments

This post contains full instructions on how to upgrade to Ubuntu 12.04 from 10.04 or 11.10 for servers and desktops I have included both GUI and command line upgrade instructions for Ubuntu 12.04 updates.

If you have any 3rd party propriatory graphics card drivers installed it is recommended you remove them prior to the upgrade process to avoid any problems during the update, you can reinstalled them after the upgrade has completed.

Always take a backup before carrying out an operating system upgrade!

How To Upgrade to 12.04 Desktop using the GUI

This is by far the easiest way to upgrade you simple wait until the official release date of 12.04 (which is currently the 26th of April 1012) and upgrade when prompted. If this does not happen it’s probably as the servers are getting hammered by users updating you can either wait or follow the instructions below on how to carry out the network upgrade.

How to Upgrade from 11.10 to 12.o4 for Desktops using Update Manager

If Ubuntu fails to prompt you to upgrade to 12.04 Desktop you can run the update manager process manually, note these instructions are for 11.10 to 12.04 only.

  1. Run the Update Manager application from the Unity Dash

  2. In Update Manager, click on “Settings” and enter your password to start the Software Sources application

  3. Select the sub menu Updates from the Software Sources application

  4. Check the “Release upgrade - Show new distribution releases” drop down to make sure “Normal releases” is selected, and change it if otherwise

  5. Close the Software Sources application and return to Update Manager

  6. In Update Manager, click the Check button to check for new updates.

  7. If there are any updates to install, use the Install Updates button to install them, and press Check again after that is complete

  8. A message will appear informing you of the availability of the new release

  9. Click Upgrade

  10. . Follow the on-screen instructions

Upgrade from 10.04 to 12.o4 for Desktops using Update Manager

The following instructions are for 10.04 to 12.04 Desktop upgrades, this uses a network installation using update manager, please only use these instructions for 10.04 to 12.04 desktops.

  1. Open the Update Manager application from the System → Administration menu

  2. In Update Manager, click the “Settings…”, and enter your password to start the Software Sources application

  3. Select the sub menu Updates from the Software Sources application

  4. Check the “Release upgrade - Show new distribution releases” drop down to make sure “Long term support releases only” is selected, and change it if otherwise

  5. Close the Software Sources application and return to Update Manager

  6. In Update Manager, click the Check button to check for new updates

  7. If there are any updates to install, use the Install Updates button to install them, and press Check again after that is complete

  8. A message will appear informing you of the availability of the new release

  9. Click Upgrade

  10. . Follow the on-screen instructions

Ubuntu Server upgrade to 12.04 using the command line

This is my preferred method of upgrading to 12.04 as it can be ran over SSH or on any version of Ubuntu Server.

To start off with make sure update-manager-core is installed and fully up to date:

1
sudo apt-get install update-manager-core

Edit the file /etc/update-manager/release-upgrades and add set:

1
Prompt=normal

Start the upgrade process:

1
sudo do-release-upgrade

Go find a coffee…

Ubuntu 12.04 Release Date

| Comments

With the Ubuntu 12.04 release date just around the corner and the release in final beta we should be expecting a release date any day now, the estimated release date for 12.04 Precise Pangolin is the 26th of April 2012.

Until then you might want to download Ubuntu 12.04 using our instructions, just so long you use apt-get update you will eventually be updated to the final stable release when it’s out. So if you are rolling out new servers now it would make sense to use the final beta and do a apt-get update & apt-get dist-upgrade on the official Ubuntu 12.04 release date and then deploy your production servers.

Check Ubuntu Version Command

| Comments

How to check the version of Ubuntu you are running (e.g 12.04 LTS)  the first thing admins require when taking over management of a new server is to find the Ubuntu version, the following methods will find the Ubuntu version from the command line enabling admins to run the command remotely over SSH to help determine the release number.

How to Check the Ubuntu Version

The following command will show the version number from the command line on any Ubuntu release.

How to find Ubuntu version from the command line:

1
cat /etc/lsb-release

Check Ubuntu Version Command

Ubuntu also ships with a command that displays the version, from what I can tell this does exactly the same as the above command but this may change in newer releases.

1
lsb-release -a

Ubuntu version cmd

Don’t forget to subscribe and follow us on Google+