Thi's avatar
HomeAboutNotesBlogTopicsToolsReading
About|My sketches |Cooking |Cafe icon Support Thi
💌 [email protected]

Local connection between 2 computers

Anh-Thi Dinh
SkillsLinuxMacOSTools
Left aside
☝
Two computers must be connected to the same network!

Streaming games

In case you have a PC/Windows which playing games and you want to play these games on these machines but from another machine, let’s try Steam Link. Read this note for more: Stream games between 2 computers in the same local network

Control visually

  • Windows: Windows Remote Desktop or NoMachine. WRD has a better display and usage. It looks like the same as you work on the remote machine.
    • 💡 An advantage of WRD over NoMachine is that it utilizes the cmd key of macOS as the ctrl key of Windows, making copy and paste very convenient.
    • When switching between windows on your macOS, WRD transitions smoothly, while NoMachine experiences noticeable lag.
  • Linux / MacOS: No Machine.
    • Tip: use username and password on the controlled macOS machine.
    • MacOS: Don’t forget to allow Accessibility and Screen Recording for the controlled machine.

Use Windows Remote Desktop

  • No need to install external applications like NoMachine.
  • Requires Windows Pro or Enterprise edition (not available on Windows Home).
  • How to set it up:
    • Ensure both machines are connected to the same WiFi network (other configurations not tested).
    • On Windows: Search for "Remote Desktop settings" → Enable "Remote Desktop" → Keep default settings → Note your machine name (e.g., "Thi_windows")
    • On macOS: Install "Windows App" (formerly "Microsoft Remote Desktop") → Click "+" → Add PC → Enter the Windows machine name → Enter your Microsoft account credentials (not your local Windows login) → Connection should now work!
    • Tip: to not enter the credentials everytime, in the dropdown of “Credentials”, save your ones.
    • 🐛
      In case you cannot connect to the Windows machine because of error Error code: 0x104. Try to connect via IP address (IPv4 Address, eg. 192.168.61.51)
  • To share folders between machines: In the Windows App, go to Configure PC, select the "Folders" tab, tick "Redirect folders," and choose the folder on your Mac that you want to access from Windows.
    • On Windows, open File Explorer and click "This PC" to see the shared Mac folder.

Use NoMachine

💡
No Machine Service is only for the “server” side. If you wish to use a “client only” side, you don’t have to enable the No Machine Service on the client, just open the No Machine app on the client, that’s it.
☝
Don’t use nx://100.xx.xxx.x:4000, use nx://192.168.xx.xx:4000 instead!
  • It requires username and password and you are connected using your Microsoft account, don't use the username and password being set up in the System Preferences, use your Microsoft Account credentials!
  • In case you don’t see the server icon or the server isn’t running. Uninstall the app and download the newest version (make sure you know your computer is x86 or x64). Reinstall it and try again. No need to restart the computer!
  • If you want to “hide” (blank) your server’s screen after the connection is established, go to Server settings > Security > Tick Blank the physical screen when somebody connects.
  • By default, the sound is streamed to the client’s computer. If you want to turn it off, go to Server settings > Devices > uncheck Enable audio streaming and microphone forwarding.
    • Go into Server settings > Security
  • Send file from the remote computer (mac) to server (windows): on the win, right click on the NoMachine icon → Transfer a file → Upload file from the client

Browse from one PC using another's internet

I want to browse the internet using a macOS browser while routing the traffic through Windows. The same process works in reverse.
Open Chrome with proxy flag (applied only for this Chrome app)
Or system-wide proxy: macOS System Settings → Network → Choose the connected wifi → Advanced → Proxies → Enable “SOCKS Proxy”: localhost:8080

Windows (WSL) 🤝 macOS

⚠️ No need NoMachine, just being on the same WiFi network is enough!
Target: I use macOS and want to access WSL running on a Windows machine. I need to edit files on Windows using VSCode on my Mac and establish an SSH connection to the Windows WSL.
Requirement: use NoMachine and 2 machines must be in the same network. Make sure they are connected successfully via NoMachine.
Direct method:
Backup method: port forwarding (in case above method aren’t working):

Connect SSH to macOS from Windows

  • Go to System Preferences > Sharing > Remote Login, enable it. You can see the IP of the macOS here.
  • On Windows (either PowerShell or WSL)
    • You need to enter the password of the user on macOS.

Open a website running on macOS from Windows

Imagine you have an Angular app running on port 4200 on your macOS device. How can you access and view this app from a Windows computer?
  • If you want to access a web application using the macOS IP address:
    • On Windows, access the application at http://192.168.68.41:4200.
  • If you want to use http://localhost:4200 on Windows while accessing the app running on macOS:
  • Forward the port using SSH:

Linux 🤝 macOS

Connect via SSH

👉 I learned from this answer. (No need for NoMachine, just being on the same WiFi network is enough)
❇️ On the "server computer" (comp1 -- Linux)
Test: connect from comp1 to comp1 itself!
❇️ On the "client computer" (comp2 -- MacOS)
❇️ Disconnect
❇️ Copy files
Tip: You can use a smtp client (eg: CyberDuck) to make things visually

Open Jupter Notebook running on comp1

Notes: Docker, SSH.
Suppose that there is a jupyter lab server which is running on comp1 (In my case, it's running inside a docker container which is ported to comp1 via port 8888).
Then open http://localhost:8888/lab to see the result!

SSH to the docker container inside comp1

I wanna ssh to the container which is running on comp1 from comp2.
❇️ Suppose that the running container on comp1 is created from an image which hasn't set up the open-ssh by default. We will set up a server in the running container
In the docker-compose.yml
❇️ In case your image has already installed openssh-server but forgot to run it by default. We will run the ssh server on port 22 for the running container.
Add below line to Dockerfile if you wanna run the openssh-server by default
🚨
Remark
We shouldn't (cannot??) run 2 servers in parallel in the docker image (for example, one for jupyter notebook on port 8888 and one for openssh-server on port 22).
💡 In this case, you should keep the jupyter notebook running. Each time you wanna run the openssh-server, you can run
You can also do this completely from comp2
Important remark: If you enter the container's shell and then you wanna exit with exit or logout command. It also terminates the server and you have to run the server again!
☝
Don't forget to forward the port 22 (in container) to 6789 in comp1 via docker-compose.yml.
◆Streaming games◆Control visually○Use Windows Remote Desktop○Use NoMachine◆Browse from one PC using another's internet◆Windows (WSL) 🤝 macOS○Connect SSH to macOS from Windows○Open a website running on macOS from Windows◆Linux 🤝 macOS○Connect via SSH○Open Jupter Notebook running on comp1○SSH to the docker container inside comp1
About|My sketches |Cooking |Cafe icon Support Thi
💌 [email protected]
1# Create SSH SOCKS Proxy
2ssh -D 8080 -N thi@window_ip
3# keep it running
1/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --proxy-server="socks5://localhost:8080" --user-data-dir=/tmp/chrome-proxy-profile
1ssh <username>@192.168.68.41
1# Run the Angular app with
2ng serve --host 0.0.0.0
3
4# Find the IP address of your macOS
5ifconfig | grep "inet " | grep -v 127.0.0.1
6# Look for the "inet" address, e.g., "192.168.68.41"
1ssh -L 4200:localhost:4200 [email protected]
1# Knowing its name
2hostname
3# or `hostnamectl` or `cat /proc/sys/kernel/hostname`
4# mine: pop-os
5
6# Knowing current user
7whoami
8# mine: thi
9# You must know the password!!!
10
11# Install openssh-server
12sudo apt update
13sudo apt install openssh-server
14
15# Check comp1's ip
16ifconfig | grep "192.168"
17# mine: 192.168.1.115
1ssh 127.0.0.1
2# type user1's password
1# Connect via comp1's name
2ssh [email protected]
3# Type thi's password
4
5# Connect via comp1's ip
6ssh [email protected]
1exit
1# From client to remote
2scp /from/client/file.zip [email protected]:/on/remote/
3# (change the destination name)
4scp /on/client/file.zip [email protected]:/on/remote/file_renamed.zip
5
6# From remote to client
7scp [email protected]:/on/remote/file.zip /on/client/
1# server
2pop-os.local # or using ip address
3# port
422
5# username
6thi
7# password
1# On comp2
2ssh -N -L localhost:8888:127.0.0.1:8888 [email protected]
3# Remark: keep the terminal
1# Check the name of running container
2docker ps # mine: docker_ai
3
4# Go inside the running container
5docker exec -it docker_ai bash
6
7# [in the container]
8
9# Install ssh server
10apt update && apt install openssh-server && apt install nano
11# Change `root`'s password
12passwd # suppose: qwerty
13
14nano /etc/ssh/sshd_config
15# and add
16Port 2222
17PermitRootLogin yes
18
19# Restart ssh server
20/etc/init.d/ssh start
1# expose the ports
2ports:
3	- "6789:2222"
1# Test on comp1
2ssh -p 6789 root@localhost
3# enter "qwerty" password for "root"
4
5# Connect from comp2
6ssh -p 6789 [email protected]
7# enter "qwerty" password for "root"
1CMD $(which sshd) -Ddp 22
1docker exec docker_ai $(which sshd) -Ddp 22 # and keep this tab open
2# or
3docker exec -d .... # detach mode
1ssh [email protected]
2# Then you are in comp1's terminal
3docker exec ....
1# On comp1
2docker exec <container_name> $(which sshd) -Ddp 22
3# Keep this tab open and running
1# On comp2
2ssh -p 6789 [email protected]
3# enter pwd: "qwerty" as in the Dockerfile