Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[solved] ssh without asking for password?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
Cocker68
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 227
Location: Germany

PostPosted: Sat Oct 29, 2005 5:26 pm    Post subject: [solved] ssh without asking for password? Reply with quote

How can I get ssh not to ask for a password, but to exit with a return code !=0, when passwordfree authentication is not possible?

I want to test in a script, if passwordfree ssh is possible, before proceeding with other actions:
Code:
ssh remote.host true
if [ $? -eq 0 ]; then
    echo "passwordfree ssh to remote.host is possible"
else
    echo "passwordfree ssh to remote.host is not possible"
fi

I also tried the -q and -qq options, but to no avail. ssh keeps asking for a password, and my script hangs forever.
The next question is, how to avoid the prompt "Are you sure you want to continue connecting (yes/no)?" when remote.host is not listed in Your known_hosts-file.

How can I use ssh in a script-safe way?

- Cocker :wq


Last edited by Cocker68 on Sun Oct 30, 2005 10:48 am; edited 1 time in total
Back to top
View user's profile Send private message
bonbons
Apprentice
Apprentice


Joined: 04 Sep 2004
Posts: 250

PostPosted: Sat Oct 29, 2005 7:59 pm    Post subject: Reply with quote

Does calling ssh with stdin redirected to /dev/null help?
Back to top
View user's profile Send private message
lbrtuk
l33t
l33t


Joined: 08 May 2003
Posts: 910

PostPosted: Sun Oct 30, 2005 2:16 am    Post subject: Reply with quote

In your ~/.ssh/ssh_config, set PasswordAuthentication to no.

Then I think it should just fail.

man ssh_config for more related settings, like PreferredAuthentications.
Back to top
View user's profile Send private message
Cocker68
Apprentice
Apprentice


Joined: 16 Jan 2003
Posts: 227
Location: Germany

PostPosted: Sun Oct 30, 2005 10:47 am    Post subject: Reply with quote

bonbons wrote:
Does calling ssh with stdin redirected to /dev/null help?

You mean ssh -n remote.host? Sorry, that didn't help.
lbrtuk wrote:
In your ~/.ssh/ssh_config, set PasswordAuthentication to no

This is not quite correct, but pointed me to the right direction. Thank You both.

Actually I had to put into $HOME/.ssh/config:
Code:
Host *.domain1.local *.domain2.local remote.host
BatchMode yes
StrictHostKeyChecking no


This provides, what I want...
Code:
# ssh remote.host
Permission denied (publickey,keyboard-interactive).
# echo $?
255

... in those cases:
  • The authenticity of host 'remote.host (192.168.240.1)' can't be established
  • my public key is not listed in remote.host's authorized_keys-file


When I want this behaviour only in particular cases, I can specify the configuration file together with invocation of ssh. This keeps usual behaviour of ssh, like it is.
Code:
# ssh -F ssh_config.backup remote.host

- Cocker :wq
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum