2

Passwordless SSH (Public Key Authentication) for CentOS 5, CentOS 6, Ubuntu, Debian, Linux in General


Scenario:

You have two servers, ServerA and ServerB – you would like ServerA to be able to SSH in to ServerB without a password. Use this simple tutorial to achieve this:

 

Step 1: Generate public key on ServerA

SSH in to ServerA and enter the following command. Keep pressing enter (accept the defaults) – do not enter a passphrase.
ssh-keygen -t dsa

This should have generated a file, /root/.ssh/id_dsa.pub

Copy the contents of the file above:
cat /root/.ssh/id_dsa.pub

Step2: Copy ServerA’s public key to ServerB

SSH in to ServerB and paste the contents from /root/.ssh/id_dsa.pub from ServerA (above) in to /root/.ssh/authorized_keys on ServerB:

If the /root/.ssh directory does not exist, create it first:
mkdir /root/.ssh
vim /root/.ssh/authorized_keys

Set the required permissions on the authorized_keys file:
chmod 0600 /root/.ssh/authorized_keys
 

Now try and SSH to ServerA from ServerB – you should not be prompted for a password. The same process can be used for other users, apart from root. If you want ServerB to have passwordless SSH access to ServerA, perform the same steps as above, but swap ServerA for ServerB the next time you do it.

Random Posts Recent Comments

  • Tony Says:

    Thanks it works! Just close the cmd windows and open a new one...

  • greenhart Says:

    I found another way around it. For the /format switch I used: /format:"%WINDIR%\system32\wbem\en-...

  • Jari Aalto Says:

    To determine OS, you can also use command lsb_release(1). See the options how to extract only part o...

  • shadovice Says:

    thanks! it worked like a charm, although there is still minor typo remained: rpm -Uvh http://downlo...

  • Joh Says:

    Great, thank you. Also works with the new version and Centos 6.3 without test repo, just install ...

  • sierprinsky Says:

    Muchas gracias por tu aporte :)...

  • kilby Says:

    The listed solution worked fine for me under Win7 64bit Though I had to run the copy as Asministr...

  • Viper5112 Says:

    The files are already in the C:\Windows\SysWOW64\wbem\en-US and they need to be in the system32 fold...

  • slowmOoh Says:

    Thanks...

  • Jørgen Says:

    @Jordan, I had the same problem also on Windows 7 64 bits. It worked for my user account and Admini...

Tag Cloud

backup mail backup mail server backup mailserver backup mx cd burner control multiple computers with one keyboard and mouse control panel DAG disk benchmark disk performance test DNS DNS check enable dag repo free cd burner free DNS check hdd benchmark http proxy install keyboard over network kloxo kloxo 64-bit kvm lxadmin lxadmin-master lxlabs mouse over network mtr ping plotter proxy proxy hide IP qmail repo RPM rpmforge share keyboard and mouse over network share keyboard over network share mouse and keyboard share mouse over network software kvm squid squid hide IP squid proxy trace traceroute tracert