Side tools: Clipboard Bridge (FreeBSD to Windows)

Dec 28th, 2025

Pastewin

This is a minimal setup to copy text from a FreeBSD (or Linux) shell directly into the Windows clipboard over a local network.

The idea is simple:

  • Send text over TCP from FreeBSD using nc
  • Receive it on Windows using PowerShell
  • Put the received text into the Windows clipboard

FreeBSD side

Add the following function to your shell profile (~/.kshrc, ~/.bashrc, etc.).

Adjust the IP address to match your Windows machine.


# PASTE TO WINDOWS (use the IP of your Windows box)
pastewin() {
  nc -w 1 192.168.1.100 5000
}

Usage example:


cat file.txt | pastewin
echo "Hello from FreeBSD" | pastewin

Windows side

Run the following PowerShell script on the Windows machine.

Save it as pastewin.ps1 and execute it in a PowerShell session.



Add-Type -AssemblyName System.Windows.Forms

$port = 5000
$listener = [System.Net.Sockets.TcpListener]::new(
  [System.Net.IPAddress]::Any,
  $port
)

$listener.Start()
Write-Host "pastewin listening on port $port..."

while ($true) {
  $client = $listener.AcceptTcpClient()
  $stream = $client.GetStream()
  $reader = New-Object System.IO.StreamReader($stream)

  $text = $reader.ReadToEnd()

  if ($text.Trim().Length -gt 0) {
    [System.Windows.Forms.Clipboard]::SetText($text)
    Write-Host "Clipboard updated ($($text.Length) chars)"
  }

  $reader.Close()
  $client.Close()
}

Once running, any text sent from the FreeBSD box will immediately appear in the Windows clipboard.

Notes

This is intended for trusted local networks only.

The nc options shown are for FreeBSD. Linux ships a slightly different nc, so flags may need adjustment.