How ti check if passwordless ssh is enabled between two systems


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How ti check if passwordless ssh is enabled between two systems
# 1  
Old 09-02-2009
How ti check if passwordless ssh is enabled between two systems

I am writing a script which will execute commands on remote host only if they have a passwordless ssh setup. How do i check for that in my script
# 2  
Old 09-02-2009

Make a list of hosts which have it and search the list.
# 3  
Old 09-03-2009
Place the following entry in the ~/.ssh/config

Code:
PasswordAuthentication no

Execute the script, if passwordless login is enabled then it will login and execute your script.

If not, then it will say the following error and exit...
Code:
Permission denied (publickey,password).

So it will not endlessly wait for the password prompt... and does the required thing faster ...

Hope the above helped. .. Let us know !
# 4  
Old 09-13-2009
Actually I am writing a script which will be executed in client box. Of course i cannot change the security settings (related to ssh) in there box.
Using my script the client need to connect to another host only if it is a passwordless ssh authentication. Else i need to prompt my client to create passwordless ssh authentication with that host.
Can i do this without modifying his ssh config file?
# 5  
Old 09-18-2009
This works for me:
ssh -o 'PreferredAuthentications=publickey' ${TARGET_USER}@${TARGET_SSH_HOSTNAME} "echo"

The (-o) option is a good way to temporarily override ssh_config/sshd_config settings as needed for a command-line sequence

The "echo" command is just something to run, which will exit immediately, replace it with something like 'hostname' if you really want to bulletproof your test so that hostname=$TARGET_SSH_HOSTNAME

ExitCode=0 (Success)
ExitCode=255 (Login failure)

Last edited by ckmehta; 09-18-2009 at 01:15 PM..
# 6  
Old 09-19-2009
Quote:
Originally Posted by vickylife
Actually I am writing a script which will be executed in client box. Of course i cannot change the security settings (related to ssh) in there box.
Using my script the client need to connect to another host only if it is a passwordless ssh authentication. Else i need to prompt my client to create passwordless ssh authentication with that host.
Can i do this without modifying his ssh config file?
You misunderstood Smilie

I have the feel that it is not possible to change in all the machines whereever you are trying to login !! And you need to edit the config file in your server ( the server from where you invoke your ssh), not in the client box. It is very much useful when you want to make this setting permanent.

I believe you would be able to do it once, in your machine !! Else the other solution that is suggested above !!
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

/etc/rc2.d/ check if kerberos server is enabled in the log or not

Hi, I tried to execute a command to check if Kerberos server is enabled Printer Daemon is enabled GUI Login is enabled, do advise how I check from the logs below on how to check whether the commands are valid or not? ls -all /etc/rc2.d/ total 8 drwxr-xr-x. 2 root root... (2 Replies)
Discussion started by: alvinoo
2 Replies

2. Shell Programming and Scripting

How to restrict ssh by forced commands but sftp login should be enabled?

Hi, I am trying to restrict an ssh-user to execute unwanted commands using ssh from a remote host a. So for that I am using the forced command in the authorized_keys file that will allow the ssh-user to only execute a particular command. If I did not set this, I am able to login via ssh and... (2 Replies)
Discussion started by: Anil George
2 Replies

3. UNIX for Advanced & Expert Users

Passwordless ssh

Hi I have created a user on a linux server and created a passwordless ssh key. I've echoed the key into the authorized_keys file for the user. I've added a series of forced commands to the key. From my laptop - logged in as myself - I can ssh into the server as that user and the commands... (3 Replies)
Discussion started by: steadyonabix
3 Replies

4. Shell Programming and Scripting

passwordless ssh

My main concern is, i have to login into 300 linux server and all are having same userid and password. I dont want to create any key for each server to login . Is there a way to run the shell script ? (3 Replies)
Discussion started by: Mani2512
3 Replies

5. UNIX for Dummies Questions & Answers

passwordless ssh

hi, i have tried with passwordless shh in google.. i followed the below steps ... user:~> ssh-keygen -t rsa Enter file in which to save the key (/home/cantin/.ssh/id_rsa):key.txt Enter passphrase (empty for no passphrase): Enter same passphrase again: till this step i... (0 Replies)
Discussion started by: arunmanas
0 Replies

6. Shell Programming and Scripting

Automating file transfer between two SSH enabled server.

Hi Experts, Few more words to the title, both the servers are ssh enabled but I have read only access to the second server, so I cannot automate SFTP process using RSA/DSA keys. I am using Control M to trigger the script and do not want any manual intervention to enter the password to complete... (4 Replies)
Discussion started by: nchourasiya
4 Replies

7. Shell Programming and Scripting

ssh passwordless

Hi, I want to login to a remote server and sftp files without password prompting. So, I created private-public key pair as follows: user1@server1.com .ssh]$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/user1/.ssh/id_rsa): Enter... (7 Replies)
Discussion started by: dips_ag
7 Replies

8. HP-UX

Help on passwordless ssh...

Hi, Can someone help me on ssh-keygen usage...? I used ssh-keygen after which "id.pub" file was generated in system1's > .ssh directory... I copied the same into the remote system system2 > .ssh directory as "authorized_keys" file. Now i tried ssh connection from system 1 to system... (7 Replies)
Discussion started by: EmbedUX
7 Replies

9. UNIX for Advanced & Expert Users

Generate Public key for non ssh enabled servers

I am writing a script that needs to access various servers some of which are not ssh enabled. In order to access the ssh enabled servers I am using the following command to generate the public key : ssh-keygen -t rsa Is there a similar command for the other servers as well. If I try to use... (1 Reply)
Discussion started by: ravneet123
1 Replies

10. Shell Programming and Scripting

Generate Public Key when the server is not ssh enabled

I am writing a script that needs to access various servers some of which are not ssh enabled. In order to access the ssh enabled servers I am using the following command to generate the public key : ssh-keygen -t rsa Is there a similar command for the other servers as well. If I try to use... (1 Reply)
Discussion started by: ravneet123
1 Replies
Login or Register to Ask a Question