Search code examples
sshputty

.ssh directory does not exist debian


I am trying to set up public-private key authentication by this article http://www.ualberta.ca/CNS/RESEARCH/LinuxClusters/pka-putty.html

Im on the step of adding public key into authorized_keys file, which should be located in .ssh directory. But that .ssh directory does not exist. ls -a outputs this

.    boot         etc         lib         mnt   root     srv  usr
..   dead.letter  home        lost+found  opt   sbin     sys  var
bin  dev          initrd.img  media       proc  selinux  tmp  vmlinuz

this does not show any results

find / -name 'authorized_keys'

So, should I create it, or I should install something and it will appear.

Thanks


Solution

  • Yes, you should create the .ssh directory and authorized_keys file if they don't exist.

    Create it in the home folder of the user you want to log in as.

    Try some thing like this:

    cd
    mkdir .ssh
    touch .ssh/authorized_keys
    chmod 700 .ssh
    chmod 600 .ssh/authorized_keys
    

    Then add your key to the authorized_keys file.

    Alternatively, you can use the command ssh-copy-id from the source machine to automate the process for you:

     ssh-copy-id user@host
    

    This will create the ~/.ssh directory and copy your public key into the file ~/.ssh/authorized_keys.