How to ssh to localhost without password?

后端 未结 12 771
无人及你
无人及你 2020-12-07 13:05

EDIT: Putting exactly what was done

I need to SSH localhost without password, the usual way of doing it (with public keys) do not work.

user@PC:~$ rm         


        
12条回答
  •  日久生厌
    2020-12-07 13:49

    Do the following steps

    ssh-keygen -t rsa -C "your_email@example.com"
    # Creates a new ssh key, using the provided email as a label
    # Generating public/private rsa key pair.
    

    Use the default file and empty passphrase (Simply press enter in the next 2 steps)

    # start the ssh-agent in the background
    eval "$(ssh-agent -s)"
    # Agent pid 59566
    ssh-add 
    

    Copy the contents of ~/.ssh/id_rsa.pub to ~/.ssh/authorized_keys

    Ensure following are the permissions

     ls -l .ssh/
     total 20
    -rw-r--r--. 1 swati swati  399 May  5 14:53 authorized_keys
    -rw-r--r--. 1 swati swati  761 Jan 12 15:59 config
    -rw-------. 1 swati swati 1671 Jan 12 15:44 id_rsa
    -rw-r--r--. 1 swati swati  399 Jan 12 15:44 id_rsa.pub
    -rw-r--r--. 1 swati swati  410 Jan 12 15:46 known_hosts 
    

    Also, ensure the permissions for .ssh directory are. This is also important

    drwx------.   2 swati swati    4096 May  5 14:56 .ssh
    

提交回复
热议问题