![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Rules & FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Bash Script to check Remote Host Connection | zulfikarmd | UNIX for Dummies Questions & Answers | 5 | 04-16-2008 03:53 AM |
| How to delete the files from local host to remote host | krishna176 | SUN Solaris | 3 | 03-24-2007 12:48 PM |
| FTP - Connection Closed By Remote Host | mouglybean | IP Networking | 1 | 10-26-2004 06:15 AM |
| Connection to host lost | goose | UNIX for Dummies Questions & Answers | 2 | 06-04-2002 04:32 PM |
| connection to host lost | nbiketi | UNIX for Dummies Questions & Answers | 1 | 04-25-2001 08:45 AM |
|
|
LinkBack | Thread Tools | Display Modes |
|
|||
|
check ssh connection to remote host
I am using KSH and I need to check whether the remote host has been configured with ssh public key. Is there any way we can check inside a script?
|
| Forum Sponsor | ||
|
|
|
|||
|
Of course, that's a Useless Use of Test $?
Code:
ssh $host "echo 2>&1" && echo $host OK || echo $host NOK |
|
|||
|
I got a problem here
I removed the public key config on the ssh server and then tried ssh root@$host "echo 2>&1" && echo "OK" || echo "NOK" But it came out asking password . which I dont want , what I wanted is even if its asked passwd its should come out with a non-zero exit satus. -------------------------------------------------------------------- Now let say how I got it implemented , even though a twisted way if [ -f $HOME/.ssh2/ssh2_config ] then mv $HOME/.ssh2/ssh2_config $HOME/.ssh2/ssh2_config.bkp echo "QuietMode yes\nBatchMode yes\nConnectTimeout 4" > $HOME/.ssh2/ssh2_config else echo "QuietMode yes\nBatchMode yes\nConnectTimeout 4" > $HOME/.ssh2/ssh2_config fi ssh -l root $R_HOSTNAME "date" > /dev/null CONN_STATUS=$? And if the RC is 66 , then it mean it had asked passwd and not got passwd within in the timeout period. Andas usual 0 as success. |
|||
| Google UNIX.COM |