1

I wanted to set up crontab to fetch resources from remote server to local server.

Steps used as below

In local server

  1. ssh-keygen with no passphrase
  2. copied the pubic key over to the server using SCP

In the remote server

  1. cat id_rsa.pub >> ~/.ssh/authorized_keys

  2. edited .ssh config file sudo nano /etc/ssh/sshd_config as below:

    RSAAuthentication yes
    PubkeyAuthentication yes
    ChallengeResponseAuthentication yes
    PasswordAuthentication no
    UsePam no
    
  3. reload ssh by sudo /etc/init.d/ssh reload

  4. Changed permissions:

    sudo chmod 700 .ssh
    sudo chmod 600 .ssh/authorized_keys
    

After all this configuration, neither I am able to access remote server by public key or normal login credential into remote server.

If I tried to login through PuTTy asked for my login after has been entered. Its says:

Disconnected: No supported authentication methods available (server send: publickey)

If I tried to login through SSH from local server ssh sana@127.168.1.1 it says:

Permission denied (publickey)

Server Details: Ubuntu 14.04, I set up public key with another user not with root user.

  • Your chmod command will only change the folder, not its contents, so you want to add a -r in there (or is it -R? it is the recursive flag, check the man pages). I also think you want 640 or 644 but not 100% on that. I don't see why you would want your .ssh directory to be executable under any circumstances, so at worst 600 should do. I could be wrong on that, though. My .ssh dir is all rw-rw-r-- (664) and is functional. The authorised_keys files on my servers are all rw------- (600). – XtrmJosh May 26 '16 at 10:21
  • Are you sure you are using your private key and not just trying to ssh with sana user? Take a look at support.rackspace.com/how-to/… in this section "PuTTY: Logging in with the Private Key" Note: In future whenever you try to change your ssh configuration, leave one ssh session open and check your ssh login in next terminal. – Err0rr May 26 '16 at 10:39
  • The folder is supposed to be 700, the .pub file should technically be 644, while your private key should be 600. – anonymous2 May 26 '16 at 11:44
  • Please look at help.ubuntu.com/community/SSH/OpenSSH/Keys again to verify you did everything correctly. Beyond that you can ask SSH to generate debugging messages with more details rejection reasons: ssh -vvv ... on the client and sudo sshd -ddd on the server (shut down the SSH daemon first). Please edit your question to include the output of the two (see How do I save terminal output to a file?). – David Foerster May 26 '16 at 14:28
  • I can't see anything wrong in your workflow. Hope you can get it fixed. @XtrmJosh: If you have no clue, you should think about not commenting, because most of what you said is simply wrong. – pLumo Jun 29 '18 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.