0

I have a few systems which are connected to the same network switch. All of them are running linux / Ubuntu 18.

I want to remotely access one machine to another through ssh.

That is, if I'm operating on one of the machines, I want to remotely access the other through ssh.

How can I go about it?

Assume I do not know the ip addresses of any of the machines and just have access to one of them. I would need the steps to obtain the ip addresses of the other machine. I'm ONLY allowed to operate a single machine on the same switch which I have access to

Eg. I have Machine A, B, C, D connected to switch S. I can only have access to A and nothing else.

I came across some SO answers which advised the use of arp -a but never went beyond that.

What are my options to do something like this?

  • Best solution. Plan ahead and have the systems build some kind of VPN between each other or register their IP and other information with some some service. – Zoredache Apr 22 '20 at 18:48

1 Answers1

0

Assuming its a simple switch and none of the machines have firewalld or iptabables blocking all inbound traffic I would use ping, tcpping, nmap or even just ssh and use a bash script to iterate over the available ip addresses in the network.

Assuming you know the netmask you can determine the ip range of the network and work from there.

Or you can use something like this:

#!/bin/bash

for destination in `arp -a | tail +5 | awk '{print $2}'`
do
    nslookup $destination 1>/tmp/arp$$ 2>/dev/null
    if [ `wc -l /tmp/arp$$ | awk '{print $1}'` -ge 4 ]; then
        tail -2 /tmp/arp$$ | grep Address | awk '{print $2}'
    fi
done

rm /tmp/arp$$

But that's only if you know they all have static ip addresses in the same network range or have dynamic dhcp addresses in the same range. If not only way to tell could to have a look in the switch and dump the arp table there.

discondor
  • 139
  • 3