SSH time out


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SSH time out
# 1  
Old 02-10-2010
SSH time out

My script will ssh to some main Server and just trigger a script on that server periodically. But the problem here is SSH.

Ther server where I'm logging is having a automount facility which automatically mount my home directory to the servers. Some time the SSH take more time to automount and hangs.

So, Is there any timeout option can inculde in the script for SSH, if so then how. please help me this regards.

Thanks
Senthil.
# 2  
Old 02-10-2010
I use the below options with SSH in various scripts. Sometimes i have to adjust the -n or use a -N option.

The -o ConnectTimeout=15 may just be for initial connections and therefore not help you as it sounds like your session is running but timing out somewhere and not exiting.

Code:
# SSH_OPTS :
#       ConnectTimeout=15
#                       Causes ssh to quit if not connected withint 15secs
#       StrictHostKeychecking=no
#                       Causes ssh to NOT ask for yes/no if the remote_server
#                       host key is unknown which causes the script to fail
#       LogLevel=quiet  Surpresses the banner information
#       -n              Prevents reading from stdin. Without this ssh overrides
#                       the current process (i.e the script) with itself.
#                       Used so ssh can run in the background
#       BatchMode=yes   Passphrase/Password querying will be disabled

SSH_OPTS=" -o ConnectTimeout=15 -o BatchMode=yes -o StrictHostKeyChecking=no -o LogLevel=quiet"

Then just call ssh with ssh $SSH_OPTS blahblah.

The -n may help also as running remote ssh calls within a script can just overrun your existing shell in its own process and therefore make it hard to trap output from.
# 3  
Old 02-11-2010
Thanks very much... the changes doing well in my script.. I'll get back if any issues.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Ssh script to validate ssh connection to multiple serves with status

Hi, I want to validate ssh connection one after one for multiple servers..... password less keys already setup but now i want to validate if ssh is working fine or not... I have .sh script like below and i have servers.txt contains all the list of servers #/bin/bash for host in $(cat... (3 Replies)
Discussion started by: sreeram4
3 Replies

2. Shell Programming and Scripting

Rsync from remote machine via ssh and sync by uisng find by modified time

Hi I have a requirement to rsync from remote to local machine via ssh and sync files that are changed in last n hours. pgrep to check if no other sync is running pgrep -f rsync.*/opt > /dev/null || rsync --bwlimit=10000 -avz --delete root@X.X.X.X:/var/source/ /opt/dest/ >> /home/log 2>&1... (0 Replies)
Discussion started by: robo
0 Replies

3. UNIX for Dummies Questions & Answers

Why does SSH store the fingerprints of remote host when connecting for the first time?

I was wondering why does ssh store the fingerprints of remote host when connecting for the first time? I will appreciate a detailed response, can't figure it out. (2 Replies)
Discussion started by: ChiefGandalf
2 Replies

4. Shell Programming and Scripting

Problems in analysing SSH LOG users & time

Attached is the log file that I have generated through the following script: last | head -2 |sed '2q;d' |awk '{ print $1"\t"$2"\t"$3"\t\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t" $9"\t"$10"\t"$11}'>>/var/log/logadmin/logtest.txt But now I'm unable to run the following operations on it: 1. Count... (1 Reply)
Discussion started by: Lionking93
1 Replies

5. UNIX for Dummies Questions & Answers

How to cat via ssh and sed at the same time.?

I am trying to write a script to automatically create conf files and remote servers. I would like to do all this without creating files locally and copying them . Here is what I have tried. sitename=$1 prodserver=$2 ssh $prodserver "cat > /data/$sitename.conf" << cat |sed... (5 Replies)
Discussion started by: macrossm
5 Replies

6. OS X (Apple)

Multiple hosts SSH NO PASSWORD - each time it overrides the last key gen

Hello, here is my problem: I have 20 machines that need to SSH into 1 machine throughout the day. The issue is every time I go through the process of putting my keys from one of the computers that needs to SSH to the server that needs to accept all the incoming SSH's it overrides the last one. ... (6 Replies)
Discussion started by: yoyoyo777
6 Replies

7. Solaris

ssh Long time to return prompt.

Hi All, I was installed new server M5000 on solaris10. I'am try to connect to server by ssh client (putty) after type user name and password the server take long time to return prompt to me about 30-60 second. any body can suggess me how to do it. (8 Replies)
Discussion started by: cesmk
8 Replies

8. Solaris

Telnet/ssh connection takes a lot of time.

We have three Oracle instances running on our Sun-Blade-T6300. Telnet or SSH connection to one of the instance (or to user oramach) takes a lot of time whether using putty or SecureCRT but connection to any other user is very fast. Any idea what may be causing this slow connection to this... (5 Replies)
Discussion started by: esmgr
5 Replies

9. Solaris

Setting up SSH - first time

Good day to you all. I have a server (running on SunOS 5.8) that i always got into via telnet. I have eventually decided to block telnet access to it and instead look toward using SSH. The problem is, whne i establish the SSH connection via PuTTy, i get the "Log in as" prompt, but upon... (5 Replies)
Discussion started by: de049
5 Replies
Login or Register to Ask a Question