SSH tunnel
Get Prepare
- Public IP: 172.220.69.10 (this might be change for few days) for check public ip
dig -4 TXT +short o-o.myaddr.l.google.com @ns1.google.com
- Private IP: 192.168.1.23. (every device have one, check by
ipconfig getifaddr en1
) - Open "Remote Login" and "Remote Management"
- Access to Wi-Fi your router's administration interface (usually through a web browser)
Port Forwarding
- Create a new port forwarding rule for your Mac Mini:
- External (WAN) port: Choose a port number, for example, 2222.
- Internal (LAN) IP address: Enter your Mac Mini's private IP, which is 192.168.1.23.
- Internal (LAN) port: Use port 22 (the default SSH port).
- Protocol: TCP
- Save the changes and restart your router if necessary.
Hint
External port can choose 2222, 22, 5900, 5901. If you just want terminal login, 2222, 22 will be great. For sharing screen, 5900, 5901 is recommand.
Usually External port is only for one device. But Internal port do not have to change.
Connect to screen
-
On the remote Mac, follow these steps to connect to your Mac Mini using the built-in Screen Sharing noapp:
-
Open Finder.
-
Press
Command+K
or click on "Go" in the menu bar and then click "Connect to Server." -
In the "Server Address" field, enter the following address:
arduinoCopy code
vnc://172.220.69.10:5901
Replace
5901
with the external port you chose during the port forwarding setup. -
Click "Connect."
-
Enter your Mac Mini's user account name and password when prompted.
-
Connect to Terminal
-
On the remote Mac, follow these steps to connect to your Mac Mini via SSH:
-
Open Terminal.
-
Type the following command and press Enter:
cssCopy code
ssh -p 2222 <your_username>@172.220.69.10
-
if you want to use X11, you can do like this
-
ssh -p 2222 -X <your_username>@172.220.69.10
Replace<your_username>
with your Mac Mini's user account name and2222
with the external port you chose during the port forwarding setup. -
Enter your password when prompted.
-
SSH auth screen sharing
- do command like:
ssh -p 2222 1234:localhost:5900 (-X) <your_username>@172.220.69.10
- Then use
open vnc://localhost:1234
to connect
THe better command is like:
ssh -L 5901:localhost:5900 -p 2222 [email protected]
This command establishes an SSH connection with port forwarding from port 5901 on your local machine to port 5900 on the remote machine. Make sure to replace tuzhenzhao
with your actual username on the Mac Mini.
Share the file outside internet
smb://172.220.69.10:8445/FIO
YOu need to know that public ip + port and give your share folder name which is important to login successful.
For check your port status
Open Port Check Tool -- Verify Port Forwarding on Your Router