Linux Crash Course – Public Key Authentication

Public Key Authentication with OpenSSH is preferred, as it’s a much stronger method of authenticating to your servers when compared to using password authentication. In fact, password authentication in OpenSSH should always be disabled. But before you can password authentication, you’ll need to set up public key authentication, and that’s exactly what we’ll do in today’s video.

YouTube player

Commands used in the Video

Check to see if a key is present already (list the storage)

ls -l ~/.ssh

Generate a key

ssh-keygen -b 4096

Follow the prompts to create the key.

Test SSH connectivity

ssh user@<ip_or_host_name>

Copy your key to a remote server

ssh-copy-id user@<ip_or_host_name>

Notable Replies

  1. just an fyi, window power shell does have ssh now, as of power shell version 7
    windows docs

  2. Nice; does it give you the ssh agent, too?

  3. I usually do not use it, but it does have it, but you need to enable it and add the path

    # By default the ssh-agent service is disabled. Allow it to be manually started for the next step to work.
    # Make sure you're running as an Administrator.
    Get-Service ssh-agent | Set-Service -StartupType Manual
    # Start the service
    Start-Service ssh-agent
    # This should return a status of Running
    Get-Service ssh-agent
    # Now load your key files into ssh-agent
    ssh-add ~\.ssh\id_ed25519

    That is what the docs say, everything works except when I add the key, it stores it in


    at least thats where mine is by default

  4. OIC, thanks. I think having the agent is lots nicer when using ssh for a lot of things, like for ansible, git, etc.

Continue the discussion at


Avatar for Buffy Avatar for system Avatar for mainedan