File tree Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Expand file tree Collapse file tree 2 files changed +15
-6
lines changed Original file line number Diff line number Diff line change 3
3
interface=$1
4
4
5
5
if [[ -z " $interface " ]]; then
6
- echo " Usage: arp-ssh enp10s0"
7
- exit 1
6
+ # Use the ifconfig command to get network interface information
7
+ ifconfig_output=$( ifconfig)
8
+
9
+ # Use grep and awk to extract the name of the active interface
10
+ interface=$( ip -o link show | awk ' $2 != "lo:" && $9 == "UP" {print $2}' | cut -d " :" -f 1)
11
+
12
+ if [[ -z " $interface " ]]; then
13
+ echo " Error: failed to auto-detect active network interface."
14
+ exit 1
15
+ fi
16
+
17
+ echo " Active network interface: $interface "
8
18
fi
9
19
10
20
# Scan the local network interface for devices
Original file line number Diff line number Diff line change 2
2
3
3
# Check if IP address is provided as a command-line argument
4
4
if [ -z " $1 " ]; then
5
- echo " Usage: $0 <ip_address>"
5
+ echo " Usage: ssh-retry <user>@ <ip_address>"
6
6
exit 1
7
7
fi
8
8
9
9
# Remote server details
10
10
remote_host=" $1 "
11
- remote_user=" root"
12
11
remote_port=" 22"
13
12
14
13
# SSH options
15
14
ssh_options=" -o ConnectTimeout=10"
16
15
17
16
# Function to attempt SSH connection
18
17
function try_ssh {
19
- echo " Attempting SSH connection to $remote_user @ $ remote_host ..."
20
- ssh $ssh_options -p $remote_port $remote_user @ $ remote_host
18
+ echo " Attempting SSH connection to $remote_host ..."
19
+ ssh $ssh_options -p $remote_port $remote_host
21
20
exit_status=$?
22
21
if [ $exit_status -eq 0 ]; then
23
22
echo " SSH connection succeeded!"
You can’t perform that action at this time.
0 commit comments