How do I get SSH access to a Mac, connected to another Mac by Ethernet, from a MacBookPro on the same network?

2

Ok, so the scenario is this:

I have a G5 Quad (running Leopard) with no wireless card. The G5 is connected by Ethernet to a Mac Mini (running Lion), which is picking up my AirPort Extreme network over WiFi. The Mac Mini shares its internet connection over Ethernet to the G5, enabling it to connect to the internet perfectly. I can also screen share or SSH into the G5 from the Mac-Mini without any problems.

Network layout

Now comes the trouble:

I have a MacBook Pro (running Lion) which also connects to the same WiFi network as the Mac Mini. I can see (and connect to) the Mac Mini from the MacBook Pro without trouble, but I cannot see or connect to the G5 from the MacBook Pro.

How can I configure this so that I can SSH or screen share the G5 from my MacBook Pro?

IPs and subnets of machines:

  • Mac Mini IP: 10.0.0.9
    Subnet Mask: 255.255.255.0

  • MBP IP: 10.0.0.4
    Subnet Mask: 255.255.255.0

  • G5 IP: 192.168.2.3
    Subnet Mask: 255.255.255.0

i0n

Posted 2011-10-30T20:14:39.860

Reputation: 163

Answers

0

Port forwarding VNC

If you use VNC for screen sharing it should be easy to just tunnel the port through the Mac Mini. So, from the MacBook Pro, you'd call:

ssh -L5900:192.168.2.3:5900 10.0.0.9

… where:

ssh -L<local-VNC-port>:<IP-of-G5>:<port-of-screensharing-at-G5> <IP-of-Mac-Mini>

This way, you'll have to actually connect to your localhost:5900 from the MacBook Pro (e.g. using Chicken of the VNC or a similar program).


SSH Proxy

If you can SSH from your Mac Mini to the G5, and from the MBP to the Mac Mini, then all you need is to "hop" over the Mac Mini to SSH to the G5 directly.

On your MacBook Pro, edit the file ~/.ssh/config (create it if it doesn't exist). Add the following:

Host g5
  User <username-for-Mac-Mini>
  HostName <hostname-of-Mac-Mini>
  ProxyCommand nohup ssh <hostname-of-G5> %h %p

The next time you want to connect to your G5, just call ssh g5. You will be directly connected to the G5. You could replace the host names with IPs too, if you like.

slhck

Posted 2011-10-30T20:14:39.860

Reputation: 182 472

Hey thanks for the advice. I'm mostly interested in getting ssh access, so I've been trying the above without success. I get this error: ssh_exchange_identification: Connection closed by remote host – i0n – 2011-10-31T12:20:43.087

@i0n Do you have any private key authentication set up? Can you try again with IP addresses instead of using hostnames? – slhck – 2011-10-31T12:33:56.113

I have private/public key pairs for github. I already tried it with the IPs, it didn't make any difference. – i0n – 2011-10-31T12:59:17.203

@i0n Can you check Console.app on both machines for any relevant error messages when you try SSH? Also, running ssh -v should give you more verbose output. Almost all I find online is related to a missing /var/empty directory on one machine. – slhck – 2011-10-31T13:41:31.133

No errors. If I ssh into the Mini-Mac from the MBP and then ssh into the G5 I can get access. It's a bit long winded but it works, if I can automate the forwarding I'm home and hosed! – i0n – 2011-11-01T21:21:00.673

@i0n Maybe you can set up SSH forwarding similar to the VNC forwarding? Like here. Otherwise, you could maybe pass the ssh command to ssh, so the two get executed after each other.

– slhck – 2011-11-01T21:41:22.320

1In the end I just settled for: ssh -t ian@Mini-Mac.local ssh ian@G5.local – i0n – 2011-11-01T22:09:45.183

Feel free to answer your question yourself with the steps that worked for you! – slhck – 2011-11-01T22:20:02.083