-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsshwait
executable file
·52 lines (49 loc) · 1.49 KB
/
sshwait
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env bash
#
# Requirements:
# - ssh
#
# Author: James Cherti
# URL: https://github.com/jamescherti/bash-stdops
#
# Description:
# ------------
# This script repeatedly attempts to check the availability of the SSH server on
# the host provided as the first argument. It exits with a 0 status upon
# successfully establishing a connection at least once. Note that it only
# verifies if the SSH server is reachable and does not provide a shell prompt or
# execute any commands on the remote host.
#
# Usage: ./script_name.sh <host>
#
# License:
# --------
# Copyright (C) 2012-2025 James Cherti
#
# Distributed under terms of the GNU General Public License version 3.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# -*- coding: utf-8 -*-
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <ssh-args-except-command>"
exit 1
fi
HOST="$1"
while true; do
if ssh -q -o BatchMode=yes "$HOST" true; then
exit 0
fi
sleep 1
done