Announcement

Collapse
No announcement yet.

Is it possible to set up password-less SSH login?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is it possible to set up password-less SSH login?

    Is it possible to login to a remote server via ssh without having to enter the password every time.

    How to set it up?

    Is a different command required to execute a password-less session?

  • #2
    This is actually a poor security practice. I am not sure about if this is possible but you will require enabling PermitRootLogin in /etc/ssh/sshd_config for making this work.

    Comment


    • #3
      Try the below command:
      Code:
       ssh-keygen
      Then you'll need to copy the new key to your server:
      Code:
       ssh-copy-id [email protected] ## or if your server uses custom port no: ssh-copy-id "[email protected] -p 1234"
      After the key is copied, ssh into the machine as normal:
      Code:
       ssh [email protected]
      You can now login without entering a password from the particular machine you executed the commands at.

      Example

      Code:
      [email protected]:~$ ssh-keygen
      Generating public/private rsa key pair.
      Enter file in which to save the key (/home/not-marco/.ssh/id_rsa):
      Created directory '/home/not-marco/.ssh'.
      Enter passphrase (empty for no passphrase):
      Enter same passphrase again:
      Your identification has been saved in /home/not-marco/.ssh/id_rsa.
      Your public key has been saved in /home/not-marco/.ssh/id_rsa.pub.
      The key fingerprint is:
      b1:25:04:21:1a:38:73:38:3c:e9:e4:5b:81:e9:ac:0f [email protected]
      The key's randomart image is:
      +--[ RSA 2048]----+
      |.o= . oo.        |
      |*B.+ . .         |
      |*=o .   o .      |
      | = .     =       |
      |. o     S        |
      |E.               |
      | o               |
      |  .              |
      |                 |
      +-----------------+
      
      [email protected]:~$ ssh-copy-id [email protected]
      [email protected]'s password:
      Now try logging into the machine, with "ssh '[email protected]'", and check in:
      
        ~/.ssh/authorized_keys
      
      to make sure we haven't added extra keys that you weren't expecting.
      Explanation


      With this, it is assumed you already can successfully connect to your server via SSH.

      You'll need to generate an SSH Keypair which will allow you to identify you as yourself without using a password. You can also protect keys with a passcode if you wish, but this can be left blank allowing totally password-less SSH access.
      1. First create your SSH Keypair by running ssh-keygen this will create an id_rsa and id_rsa.pub file. The pub file is what goes on the servers, the private key (id_rsa) is what stays with you and is how you identify yourself.
      2. Next copy the public key to your server with ssh-copy-id [email protected] replacing user with your remote user and server with the machine DNS name or IP address. It'll prompt for your SSH password, enter it and if all completes successfully you'll be able to access the machine via ssh [email protected] without needing a password.

      Comment

      Working...
      X