0

I am doing the same steps (Perform SSH and SCP Without Entering Password on openSSH). But it keep asking password prompt while scp or 'ssh -l' command run. Same steps i did few days back, it was working fine, but now it is not working.

What i did was:

  1. I have two machines LOCAL and REMOTE.
  2. In both machines, I login in putty with root user.
  3. In both machines, I checked 'ssh -V', i find same version same product in both.
  4. in local, i run from /root/.ssh folder

ssh-keygen

i gave key file name as appkey. 5. it generated appkey, appkey.pub in /root/.ssh 6. In remote, i copied content of local appkey.pub and pasted in at the end of remote authorized_keys file. 7. In remote, i run

chmod 755 ~/.ssh chmod 644 ~/.ssh/authorized_keys

  1. In local, i tried to run scp and 'ssh -l' commands, but it still asking passwords.
  2. I tried other way also, instead of adding in authorized_keys file, i copied appkey.put to romote /root/.ssh folder
2
  • what is the error message by typing ssh -vvv
    – Kit Ho
    May 23 '13 at 6:39
  • ~/.ssh must be chmod 700, not 755.
    – Kent
    May 28 '13 at 7:30
2

You need also to check your home permission to make sure that nobody can write to it. Otherwise strangers can rename your .ssh and create their own .ssh. I have this initial ssh setup which I created a few years ago and which helped many people:

#!/bin/csh -fx

chmod go-w ~
if (! -d ~/.ssh) then
   rm -rf ~/.ssh
   mkdir ~/.ssh
endif
chmod 700 ~/.ssh
cd ~/.ssh
touch authorized_keys
chmod 600 authorized_keys
rm -f id_rsa
# generate id_rsa and id_rsa.pub
ssh-keygen -t rsa -f id_rsa -P ""
cat id_rsa.pub >> authorized_keys
# for remote host:
# cat ~/.ssh/id_rsa.pub | ssh HOST 'cat >> ~/.ssh/authorized_keys'
# it is the same as:
# ssh-copy-id -i id_rsa.pub USER@HOST
# it will add mulptiple entries if called multiple times

I am not an expert in this, just collected pieces in Web. Something may be outdated but works in our environment.

1
  • What i did was:
    – Sun
    May 28 '13 at 6:55
0

did you try specifying which exact keyfile to use when you are issuing the ssh command from your local server as follows ?

ssh -i /root/.ssh/appkey -l remote_username remote_servername

otherwise, ssh assumes your private key name as you can see from the following excerpt from ssh man page.

 ...
 -i identity_file
     Selects a file from which the identity (private key) for RSA or
     DSA authentication is read.  The default is ~/.ssh/identity for
     protocol version 1, and ~/.ssh/id_rsa and ~/.ssh/id_dsa for pro-
     tocol version 2.  Identity files may also be specified on a per-
     host basis in the configuration file.  It is possible to have
     multiple -i options (and multiple identities specified in config-
     uration files).
  ...
1
  • sorry, tried not working.........
    – Sun
    May 28 '13 at 6:14
0

Jackua, You solved my problem. it solved by doing like this:

  1. Deleted existing .ssh(renamed as .ssh_bck) folder.
  2. I did the same steps as you mentioned.
  3. I used ssh-copy-id -i id_rsa.pub USER@HOST
  4. To confirm with command 'ssh 'USER@HOST'' not asking for password.
  5. run cat .ssh/authorized_keys To verify multiple entities or single entity exist in file.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.