Menu

Notes

this is kinda drafts of the posts, unpolished thingies. I started writing this because, I always think, i will write a post on it later and procrastinate until i forget

Setting Up Mosh

9/21/2025

Mosh can be best described as an alternative to ssh.
It is very useful when the network is pretty weak or the network has high latency.

Even though I’ve heard and used mosh a little bit before, only recently I started using it all the time.

it was due to me buying a VPS from OVH (the stocks were pretty limited and only available at certain times) at Europe or something and when I tried to do some serious work on that VPS while connected to ssh, the latency became a bottleneck.

In ssh, when we type a character, that character travels all the way to the vps and after the confirmation from the vps reaches our device, we can actually see the character in our system.

because of that, using ssh in unreliable connections is very problematic.

but mosh on the other hand, does some little things to make our life easier.

ie, if the network is too slow or the latency is too much, instead of waiting the confirmation from the server, mosh shows them instantly on our terminal. I’ve learnt that the official term for this is ‘predictive echo’ or something.

Apart from this, another feature is, it NEVER disconnects. ie, even if we change networks, whether its switching between different wifi networks or switching between wifi and mobile networks, the mosh session won’t be disconnected. It also survives even if we put our device to sleep :)

if mosh is unable to connect to the server for some time, it will show a friendly message saying mosh: Last contact <n> seconds ago. and if we reconnect it, it’ll instantly show the latest view of the terminal.

Setup

first, we need to install the mosh package on both server and client. for ubuntu/debian family etc, it’s available in the apt repo. we can install it by running

apt update && apt install mosh -y

after that, we need to install it on our client. for macos it’s available in the homebrew.

brew install mosh

for termux, we can install it from pkg

pkg update && pkg upgrade && pkg install mosh

After installing on both client and server, we can simply connect to our server by changing to mosh instead of ssh

mosh root@<my-ip-address>

ie, we only need to change the word ssh to mosh in our commands

setting up tailscale on a new vps

9/20/2025

After buying the vps, login to it using the normal ssh way.

ssh root@<your-ip-address>

after logging in, install tailscale by going to the tailscale dashboard, click Add device, click Linux Server

in the new page, go all the way down and click the Generate Install Script button

it’ll give a script like this.

curl -fsSL https://tailscale.com/install.sh | sh && sudo tailscale up --auth-key=<random-text-blablablabla>

run that command on the vps and we’ll see a message like this

Installation complete! Login in to start using tailscale by runing: tailscale up

there’s a small note here. ie, if we run tailscale up --ssh instead of the recommended command, we can login to this vps without entering password everytime from the devices on our tailscale network.

for getting our tailscale ip address, we can run tailscale ip command.

it’ll output something like 100.94.23.102

from now on, we can login to our vps using this ip address from the devices on our tailscale network and it won’t ask for password.

ie, ssh [email protected] will allow us to connect to our vps from any device on our tailscale network

Since we’ve added our device to the tailscale network, we can block the default ssh port 22 for the rest of the world. we can use ufw for that.

ufw default deny incoming
ufw default allow outgoing
ufw allow in on tailscale0
ufw enable

the above commands will block all incoming traffic from the normal internet, allow outgoing traffic from our vps to the internet and allow any traffic only through tailscale.

if you get errors like ufw: command not found, we first need to install ufw by running this.

apt update && apt install ufw -y

after that, we can rererun the above commands and it should work

fix for Mosh Server in macos error: command not found `mosh-server`

9/19/2025

if you’re trying to remotely access your macbook through mosh after installing the mosh cli through homebrew, we may get this error.

zsh:1: command not found: mosh-server Connection to 100.94.16.82 closed. /usr/bin/mosh: Did not find mosh server startup message. (Have you installed mosh on your server

it’s because, mosh logins using ssh at first, then spawn a mosh-server.

but at that point, path entries on the .zshrc, .zprofile files are not loaded.

for the fix, we need to add the homebrew path to the padin the a file named .zshenv. this file will be read before anything else.

for the below content to the .zshenv file and the mosh should work properly

# Add Homebrew to PATH
export PATH="/opt/homebrew/bin:$PATH"

Working with xcode projects in VSCode

9/17/2025

If you’re familiar with vscode but hate the ui of xcode, you can open your projects in vscode.

Open the terminal in the project directory and run code . to open it in vscode

At this point, when we open a swift file, we can’t use language features like clicking on a function to go to definition and all. For that, we need to install 2 more extensions.

  • SweetPad
  • Swift official extension

Then click cmd+shift+P to open the vscode command palette and search for SweetPad: Generate Build Server Config and click enter.

It’ll create a buildServer.json file.

If we open a Swift File again, we’ll have rich language features. ✨

Debugging

If the language features not working after these steps, try the below.

  1. Reload the vscode by running Developer: Reload Window from the vscode command palette
  2. Select the Xcode Toolchain by running Swift: Select Toolchain from the vscode command palette.

Happy coding :)