Oct 30, 2011
jason

How to install sshd and config for authentication with private key only

Once the system is up and running, the first thing for most linux system admin to do is to install sshd and configure authentication. Nowadays, most IT companies will not allow password based authentication anymore. Most coporate environment favours ssh key based authentication. Of course, there are hundreds of different methods to do this. Here is one of my favourite and simplest guide.

I’ve assumed you use Debian based linux and logon under root. If you are using other linux, change the command to yum or whatever package management system you used.

  • First install ssh server.
  • ~$apt-get install openssh-server

  • Edit sshdconfig file
  • ~$vi /etc/ssh/sshd_config

  • Disable password authentication by putting the following line
  • PasswordAuthentication no

  • For keys file location, I prefer to put in file by user name
  • AuthorizedKeysFile /etc/ssh/keys/%u

  • Save the file
  • Copy the public key of the users and put in /etc/ssh/keys/
  • Restart the ssh demon by entering the following command
  • /etc/init.d/ssh restart

That’s it! Your users need to use their private key to login to the server from now on.

Source : OpenBSD

Leave a comment