Skip to content

Commit b0a5d9a

Browse files
author
timon
committed
improve ux
1 parent b811767 commit b0a5d9a

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

script/arp-ssh.sh

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,18 @@
33
interface=$1
44

55
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"
818
fi
919

1020
# Scan the local network interface for devices

script/ssh-retry.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,21 @@
22

33
# Check if IP address is provided as a command-line argument
44
if [ -z "$1" ]; then
5-
echo "Usage: $0 <ip_address>"
5+
echo "Usage: ssh-retry <user>@<ip_address>"
66
exit 1
77
fi
88

99
# Remote server details
1010
remote_host="$1"
11-
remote_user="root"
1211
remote_port="22"
1312

1413
# SSH options
1514
ssh_options="-o ConnectTimeout=10"
1615

1716
# Function to attempt SSH connection
1817
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
2120
exit_status=$?
2221
if [ $exit_status -eq 0 ]; then
2322
echo "SSH connection succeeded!"

0 commit comments

Comments
 (0)