Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Script that tries to connect via SSH till connection is up Post 302842719 by OdedOvdat on Friday 9th of August 2013 05:51:47 PM
Old 08-09-2013
Script that tries to connect via SSH till connection is up

Hey,

I need a script that tries to connect via SSH to a remote server
and that remote server might not be up yet, so retry until succeed
the error message I get if the server is not up yet is:
Code:
ssh: connect to host 127.0.0.1 port 40001: Connection refused

any idea of a good way to do it ?

Thanks!

Last edited by OdedOvdat; 08-12-2013 at 04:33 PM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remote SSH Connection Using Script

Hi, I am new to Shell Scripting. Can anybody help me in writing a Script Which Could Login from a Unix box to a Remote Unix box which accepts the user credentials automatically and display the result for checking the Disk Space Utilisation (Without running any SSH agent). (1 Reply)
Discussion started by: ajith_tg
1 Replies

2. Shell Programming and Scripting

script to connect to different ip address thro telnet or ssh

Hi, I have three ip address say x.x.x.x , y.y.y.y and z.z.z.z I am connecting to x.x.x.x first and from there i do telnet or ssh to y.y.y.y and getting into y and from there i do telnet or ssh to z.z.z.z i want to know, can we write a script, which can automatically connect from x to y... (3 Replies)
Discussion started by: vasikaran
3 Replies

3. Shell Programming and Scripting

ssh connection script

Hi all, I'm writing a script that chooses the best computer available in an open lab. The script works great except every now and then there is a dead computer in the lab that begins the ssh handshaking, but freezes after the following: debug1: Offering public key: When the script happens... (2 Replies)
Discussion started by: x-375HK-x
2 Replies

4. Shell Programming and Scripting

shell script for how to connect to a remote server by using ssh

i want to connect to a remote server through ssh. i have to also provide password within that script. after connecting to the remote server i want to do some operations like grep,cd etc can u pls help me to wite a script. Thanks (1 Reply)
Discussion started by: millan
1 Replies

5. Shell Programming and Scripting

how to terminate ssh connection without terminating script

Hi all, I connect with SSH connection to remote machine in the script and ı want to logout at half of the script then continue to script. If ı write exit in the script it terminates script not SSH connection. How can i do that please help me (1 Reply)
Discussion started by: fozay
1 Replies

6. Shell Programming and Scripting

SSH Connection drops - but does my script keep running?

Hello there. I'm fairly new to Linux, but I am connecting via SSH and PuTTY to a remote server, and I am running a fairly heavy MySQL script in a PHP page. Our connection here is dodgy to say the least and I get continuous disconnections. My question is, when I get disconnected, does my... (4 Replies)
Discussion started by: christatedavies
4 Replies

7. Shell Programming and Scripting

Mysql command after a SSH connection (Script)

Hi all, Im new at scripting and i need to run a few commands at work every hours so i decide to make a script but on 1 of the steps i have a the follwoing problem: The command i do is this: #!/bin/bash ssh root@asdasd001 'mysql -h A-db-1 -uroot -password --execute "show slave status"'... (3 Replies)
Discussion started by: Aparicio
3 Replies

8. Shell Programming and Scripting

Passing password in script for ssh connection - no except

Used the script posted on forum - unix.com/shell-programming-scripting/21597-script-change-passwords-same-user-multiple-servers.html but the last question posted on this seems to be still unanswered, tried different things with no success, can someone help giving an way to pass the password via... (5 Replies)
Discussion started by: sapadmin
5 Replies

9. Shell Programming and Scripting

Shell script to connect to multiple ssh servers

Hello, I have access to several linux servers (mostly centos based) located in a DC in another country. from day to day I need to login to each of them to do some work (they dont have gui/window manager installed, I work only from console), or even to just do a check like df -h for disc usage.... (3 Replies)
Discussion started by: MaRiOsGR
3 Replies

10. 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
CONNECT-PROXY(1)					      General Commands Manual						  CONNECT-PROXY(1)

NAME
connect-proxy -- connect over SOCKS4/5 proxy SYNOPSIS
connect-proxy [-dnhst45] [-R resolve ] [-p local-port ] [-w secs ] [-H [user@]proxy-server[:port]] ] [-S [user@]socks-server[:port]] ] [-T proxy-server[:port] ] [-c telnet-proxy-command ] [host] [port] DESCRIPTION
connect-proxy open connection over SOCKS4/5 proxies Please, note that any HTTP-Proxy tunnel won't work with content-inspection firewall (unless using SSL). OPTIONS
-H specifies a hostname and port number of the http proxy server to relay. If port is omitted, 80 is used. You can specify this value in the environment variable HTTP_PROXY and pass the -h option to use it. -S specifies the hostname and port number of the SOCKS server to relay. Like -H, port number can be omitted and the default is 1080. You can also specify this value pair in the environment variable SOCKS5_SERVER and give the -s option to use it. -4 specifies SOCKS relaying and indicates protocol version to use. It is valid only when used with '-s' or '-S'. Default is '-5' (protocol version 5) -R method to resolve the hostname. Three keywords ("local", "remote", "both") or dot-notation IP address are acceptable. The key- word "both" means, "Try local first, then remote". If a dot-notation IP address is specified, use this host as nameserver. The default is "remote" for SOCKS5 or "local" for others. On SOCKS4 protocol, remote resolving method ("remote" and "both") requires protocol 4a supported server. -p will forward a local TCP port instead of using the standard input and output. -P same to '-p' except keep remote session. The program repeats waiting the port with holding remote session without disconnecting. To connect the remote session, send EOF to stdin or kill the program. -w timeout in seconds for making connection with TARGET host. -d used for debug. If you fail to connect, use this and check request to and response from server. USAGE
To use proxy, this example is for SOCKS5 connection to connect to "host" at port 25 via SOCKS5 server on "firewall" host. connect-proxy -S firewall host 25 SOCKS5_SERVER=firewall; export SOCKS5_SERVER; connect-proxy -s host 25 For a HTTP-PROXY connection: connect-proxy -H proxy-server:8080 host 25 HTTP_PROXY=proxy-server:8080; export HTTP_PROXY; connect-proxy -h host 25 To forward a local port, for example to use ssh: connect-proxy -p 5550 -H proxy-server:8080 host 22 ssh -l user To use it along ssh transparently: # file://~/.ssh/config # not using proxy on lan Host 192.* ProxyCommand connect-proxy %h %p # mandatory to access the internet Host * ProxyCommand connect-proxy -H proxyserver:8080 %h %p Or for all users ( /etc/ssh/ssh_config ) ENVIRONMENT
SOCKS5_USER, SOCKS5_PASSWORD, HTTP_PROXY_USER, HTTP_PROXY_PASSWORD, CONNECT_PASSWORD, LOGNAME, USER SEE ALSO
ssh (1). WWW
http://www.meadowy.org/~gotoh/projects/connect AUTHOR
This manual page was written by Philippe Coval rzr@gna.org for the Debian system (but may be used by others). Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. On Debian systems, the complete text of the GNU General Public License can be found in /usr/share/common-licenses/GPL. CONNECT-PROXY(1)
All times are GMT -4. The time now is 08:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy