Ubuntu Key Only Access

How to setup an Ubuntu Server for key access only

https://linuxaws.wordpress.com/2017/07/17/how-to-generate-pem-file-to-ssh-the-server-without-password-in-linux/

Instructions

  1. How to configure an Ubuntu Server for pem keys

    On the server in question run the following
    cd /home/ubuntu/.ssh (create this directory if it doesn't exist)
    ssh-keygen -t rsa -b 2048 -v
    The command above produces two files rsa_id and rsa_pub
    copy rsa_id to <some file name>.pem (this is your pem key)
    chmod 700 ~/.ssh directory
    touch ~/.ssh/authorized_keys (do this if the file is not already present)
    chmod 600 ~/.ssh/authorized_keys
    cat rsa_pub > ~/.ssh/authorized_keys
    THEN EDIT /etc/ssh/sshd_config
    ADD OR EDIT THESE
    RSSAAuthentication yes
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys
    PasswordAuthentication no
    ChallengeResponseAuthentication no
    UsePAM yes

    THEN RESTART SSHD
    sudo systemctl restart sshd

Download the <some file name>.pem key to your machine

Then ssh -i <some file name>.pem ubuntu@yourserverip.com