View previous topic :: View next topic |
Author |
Message |
Cocker68 Apprentice
Joined: 16 Jan 2003 Posts: 227 Location: Germany
|
Posted: Sat Oct 29, 2005 5:26 pm Post subject: [solved] ssh without asking for password? |
|
|
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 |
|
|
bonbons Apprentice
Joined: 04 Sep 2004 Posts: 250
|
Posted: Sat Oct 29, 2005 7:59 pm Post subject: |
|
|
Does calling ssh with stdin redirected to /dev/null help? |
|
Back to top |
|
|
lbrtuk l33t
Joined: 08 May 2003 Posts: 910
|
Posted: Sun Oct 30, 2005 2:16 am Post subject: |
|
|
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 |
|
|
Cocker68 Apprentice
Joined: 16 Jan 2003 Posts: 227 Location: Germany
|
Posted: Sun Oct 30, 2005 10:47 am Post subject: |
|
|
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 |
|
|
|
|
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
|
|