Activate password authentication on Ubuntu VMs on Amazon EC2

ssh -i [path to private-key-file] [target IP]

# In the host shell

sudo adduser [username]     # Add a new user; this command also prompts for setting the password

sudo adduser admin            # Add this user to the admin group (to sudoers)

sudo vi /etc/ssh/sshd_config

# In the above file set "PasswordAuthentication" to "yes".

sudo reload ssh

The VM should now be ready for password based ssh authentication.

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!