Temporarily enable SSH password authentication on RHEL/Centos VMs.

To enable password based authentication on RHEL/Centos machines, login as root to the target host. ( sudo the commands below if you are not logging in as root)

1. Create the password authenticated user if not already created –

  • On console run : adduser [username]
  • Set a password for the new user: passwd [username]

2. Add the user to sudoers and enable remote login –

  • On console run: visudo
  • In the file opened for editing, comment out the line – “Defaults    requiretty
  • Add the line “[username] ALL=(ALL)       ALL”  below the line “root ALL=(ALL)       ALL

3. Enable password authentication for SSH.

  • vi /etc/ssh/sshd_config
  • Replace the line “PasswordAuthentication no” with “PasswordAuthentication yes“. (Uncomment this line if commented.) Save and close this file.
  • /etc/init.d/sshd reload

4. To disable password authentication after use, in the above file replace “PasswordAuthentication yes” with “PasswordAuthentication no“; reload sshd as before.

Fix Vim editor on Ubuntu

Problem: The arrow keys insert characters, no status message at the bottom etc.

Reason : The default Vim on Ubuntu is vim-tiny, a skeleton version.

Fix: Install the real stuff – sudo apt-get install vim

Note: vi = Visual, vim = Visual improved. And vim-tiny is vi compatible, kind of Jurassic.

Install Sun (Oracle) Java on Ubuntu without using PPAs

Install JDK on Ubuntu manually without depending on PPAs –

  1. Select the required package from here – http://www.oracle.com/technetwork/java/javase/downloads/index.html. Download the jdk-[version].bin file from the downloads page.
  2. Make the downloaded file runnable; Eg – sudo chmod +x jdk-6u32-linux-x64.bin
  3. Run this file; Eg- sudo ./jdk-6u32-linux-x64.bin
  4. Move the newly created folder to /usr/lib/jvm/. Eg – sudo mv jdk1.6.0_32 /usr/lib/jvm/ (Optionally change the user of this folder to yourselves)
  5. Add the newly added jdk to known java command option –
    sudo update-alternatives --install "/usr/bin/java" "java" "/usr/lib/jvm/jdk1.6.0_32/bin/java" 1
    sudo update-alternatives --install "/usr/bin/javac" "javac" "/usr/lib/jvm/jdk1.6.0_32/bin/javac" 1
    sudo update-alternatives --install "/usr/bin/javaws" "javaws" "/usr/lib/jvm/jdk1.6.0_32/bin/javaws" 1
  6. Choose the new java, javac and javaws by running commands-
    sudo update-alternatives --config java
    sudo update-alternatives --config javac
    sudo update-alternatives --config javaws

Run java -version to verify installation. Cheers!

Eclipse Compilation error: [function/type] is not accessible due to restriction on required library … rt.jar

Problem : Eclipse gives the error – “[function/type] is not accessible due to restriction on required library … rt.jar” when building a project.

Reason: Project  classpath (in the build path) is refers to JRE in place of the JDK in which the Project is configured to work with.

Fix:  Go to Java Build Path > Libraries, choose JRE System Library, click Edit button. From the dialog choose Alternate JRE and choose the required JDK.

Create Shortcut / launcher on Desktop in Ubuntu 12.04

To create a shortcut to an application or location on the desktop (Ubuntu 12+), on terminal run –

Method 1: Installing Gnome Panel

  1. if a shortcut is being created for the first time,
    sudo apt-get install gnome-panel

    , else directly do step 2.

  2. gnome-desktop-item-edit ~/Desktop/ --create-new
  3. In the launcher-creation window choose the type and location of the target. Click OK.

Method 2: For application shortcuts only

If shortcut to an installed application is to be created –

  1. Go to Home Folder –> File System –> usr –> share –> applications.
  2. Right click your favourite icon, choose Copy To –> Desktop

(from mhdizam’s comment, verified working)