makewhatis

Random Linux Garble.

Setting Up SSH Key Authentication Centos/Fedora

I have recently had to start dealing with a lot of servers, both at work and my side business. Logging into them all the time can be a pain, and managing passwords can be pretty terrible as well. SSH Keys are really convenient for this scenario.They are, for the most part, easy to setup. I have run into a few things, especially to do with permissions on when implementing them. Here is a simplified breakdown of how to set this up on a linux machine (Centos, Fedora, RHEL)

  1. Create directories on both your local machine, as well as the server. (assuming you are on linux or mac)

    mkdir ~/.ssh

  2. Generate your ssh key pair private/public

    ssh-keygen -t rsa

  3. Copy your public key to the server and put it into the authorized_keys file.

    scp id_rsa.pub user@serverip:~/.ssh/
    cat id_rsa.pub >> autorized_keys    (this will create the file if it has not been created, as well as append the value if it already exists with data.)

  4. Change permissions on .ssh directory as well as authorized_keys file.

    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys

Thats it! You should be good to go here. Go ahead and test the login.

The main problem I have encountered in the past is when logging in via ssh, it still prompting me for the password. This is usually due to permissions on the .ssh folder as well as the authorized_keys file.