LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   ssh no password prompt (https://www.linuxquestions.org/questions/linux-software-2/ssh-no-password-prompt-325848/)

dtra 05-22-2005 12:01 AM

ssh no password prompt
 
hi all

i want to set up a cronjob that rsync's file on our web server
so i need to setup ssh so that there is no login prompt

i'm having issues though
this is what i've tried

m1 is the computer that needs to login and sync files
m2 is the computer with the files

root@m1 -> ssh-keygen -t dsa, no passphrase
root@m1 -> scp id_dsa.pub remoteuser@m2:~/.ssh/authorized_keys

still asks for password after that

when i try

root@m1 -> ssh-keygen -t dsa, no passphrase
root@m1 -> scp id_dsa.pub root@m2:~/.ssh/authorized_keys

there is no problem, exactly the same procedure, same files

i've tried it with three different computers and it always works with root@m2
but never when it is user@m2

anyone have any ideas
thanks
dave

freegianghu 05-22-2005 12:54 AM

Re: ssh no password prompt
 
Quote:

Originally posted by dtra
hi all

i want to set up a cronjob that rsync's file on our web server
so i need to setup ssh so that there is no login prompt

i'm having issues though
this is what i've tried

m1 is the computer that needs to login and sync files
m2 is the computer with the files

root@m1 -> ssh-keygen -t dsa, no passphrase
root@m1 -> scp id_dsa.pub remoteuser@m2:/.ssh/authorized_keys

still asks for password after that

when i try

root@m1 -> ssh-keygen -t dsa, no passphrase
root@m1 -> scp id_dsa.pub root@m2:/.ssh/authorized_keys

there is no problem, exactly the same procedure, same files

i've tried it with three different computers and it always works with root@m2
but never when it is user@m2

anyone have any ideas
thanks
dave

You should copy to userdirectory
Code:

scp id_dsa.pub remoteuser@m2:~/.ssh/authorized_keys
Make sure authorized_keys owner by remoteuser. @ server:
Code:

chown remoteuser remoteuser_home/.ssh/authorized_keys
chmod 600 remoteuser_home/.ssh/authorized_keys

Good luck,
Giang Hu

dtra 05-22-2005 01:17 AM

hi thanks for your reply
the authorized_keys files was copied to the user's .ssh directory
i just typed in rush format

and the authorized_keys file is owned by remoteuser

freegianghu 05-22-2005 01:28 AM

Quote:

Originally posted by dtra
hi thanks for your reply
the authorized_keys files was copied to the user's .ssh directory
i just typed in rush format

and the authorized_keys file is owned by remoteuser

Your remoteuser@server had difference uid with remoteuser@client, I think. Try out:

Code:

ssh remoteuser@server
Password:

cat ~/.ssh/authorized_keys

What does it say? (Dont tell me "Permission denied")

dtra 05-22-2005 01:42 AM

is this what you expected?
logged in as root@m1
shell root@m1] ssh remoteuser@m2
password:

shell remoteuser@m2]cat ~/.ssh/authorized_keys

it prints out the public key exactly the same as what it is on m1

freegianghu 05-22-2005 02:22 AM

Quote:

Originally posted by dtra
is this what you expected?
logged in as root@m1
shell root@m1] ssh remoteuser@m2
password:

shell remoteuser@m2]cat ~/.ssh/authorized_keys

it prints out the public key exactly the same as what it is on m1

Its seemed really strange :(. I had tested (with normal user) on my network and everything go right :-o

Code:

# login as localuser
[localuser@knoppix ~] ssh-keygen -t dsa
[localuser@knoppix ~] ssh remoteuser@gentoo mkdir ~/.ssh
Password:
[localuser@knoppix ~] scp id_dsa.pub remoteuser@gentoo:~/.ssh/authorized_keys
[localuser@knoppix ~] ssh remoteuser@gentoo ls
[localuser@knoppix ~]

Could you try again? (remove remoteuser .ssh dir before try)
Giang Hu

MiscGeek 05-22-2005 03:45 AM

Check your directory permissions for the remote user's ~/.ssh directory. SSH is very picky about permissions. It should have only drwx.

dtra 05-22-2005 04:52 AM

hey thanks guys

miscgeek, you were on the money, .ssh directory permissions were the one
it was 755 for the remote .ssh directory
changed it to 700 and voila

thanks again

freegianghu 05-22-2005 06:44 AM

Quote:

Originally posted by dtra
hey thanks guys

miscgeek, you were on the money, .ssh directory permissions were the one
it was 755 for the remote .ssh directory
changed it to 700 and voila

thanks again

Congratulation, but have you ever tried change back permission to 755? :)

vineet.k 05-25-2005 01:08 PM

Try this out
 
) Type the following script in a file named "sshlogin".

#!/usr/bin/expect --

set timeout 180
set machine [lindex $argv 0]
set username [lindex $agrc 1]
set password [lindex $argv 2]
spawn ssh $username@$machine
expect "$username@$machine's password: "
send "$password\n"
interact


2) Give executable permission to the file.

chmod 711 sshlogin

3) put this file in /bin folder

4) Now for a user "abc" wants to login to a machine node1 using password "xyz", the command is :
sshlogin node1 abc xyz

I think this should solve your problem

__________________
Vin.K
--------
touch /proc/kcore


All times are GMT -5. The time now is 12:33 PM.