This guide covers setting up SSH access from Android Termux to macOS, including NordVPN Mesh configuration for remote access.
- Prerequisites
- Mac Setup
- NordVPN Mesh Setup
- Termux Setup
- SSH Key Configuration
- Connection Methods
- Troubleshooting
- Security Tips
- macOS with admin access
- Android device with Termux installed
- NordVPN subscription (for Mesh feature)
- Local network access (for initial setup)
- Open System Settings → General → Sharing
- Toggle ON "Remote Login"
- Note which users are allowed (select "All users" or specific users)
brew install --cask nordvpnCheck SSH daemon settings:
cat /etc/ssh/sshd_config | grep -E "PubkeyAuthentication|PasswordAuthentication|AuthorizedKeysFile" | grep -v "^#"Expected output:
AuthorizedKeysFile .ssh/authorized_keys
# Create SSH directory if it doesn't exist
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Create authorized_keys file
touch ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys# Get username
whoami
# Get hostname
hostname
# Get local IP address
ifconfig | grep -E "inet " | grep -v 127.0.0.1- Open NordVPN application
- Log in with your credentials
- Go to Settings → Meshnet
- Toggle Meshnet ON
- Note your device's Mesh name (usually shows as hostname)
- Keep NordVPN running
- Install NordVPN from Google Play Store
- Log in with the same account
- Go to Settings → Meshnet
- Enable Meshnet
- Find your Mac in the device list
- Enable route traffic for the Mac device
# Update package repository
pkg update && pkg upgrade -y
# Install OpenSSH
pkg install openssh -y
# Install additional tools (optional)
pkg install openssh-tools -y# Create SSH directory
mkdir -p ~/.ssh
chmod 700 ~/.ssh
# Generate ED25519 key (recommended)
ssh-keygen -t ed25519 -C "termux@android"When prompted:
- File location: Press Enter for default
- Passphrase: Leave empty for passwordless (or set one for extra security)
cat ~/.ssh/id_ed25519.pubCopy the entire output (starts with ssh-ed25519)
- On Termux: Copy the public key output from above
- On Mac: Add the key to authorized_keys:
# On Mac
echo "YOUR_TERMUX_PUBLIC_KEY_HERE" >> ~/.ssh/authorized_keysFrom Termux (requires password once):
# Using local IP
ssh-copy-id [email protected]
# Or using Meshnet
ssh-copy-id [email protected]From Termux (requires password once):
cat ~/.ssh/id_ed25519.pub | ssh [email protected] "cat >> ~/.ssh/authorized_keys"On Mac:
ls -la ~/.ssh/
# Should show:
# drwx------ for .ssh directory
# -rw------- for authorized_keysIn Termux, create ~/.ssh/config:
cat > ~/.ssh/config << EOF
Host mac
HostName 192.168.4.52
User sandeepvishnu
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
Host mac-mesh
HostName your-mac-name.nord
User sandeepvishnu
IdentityFile ~/.ssh/id_ed25519
IdentitiesOnly yes
EOF
chmod 600 ~/.ssh/configNow connect with:
ssh mac # Local network
ssh mac-mesh # Via Meshnet-
Check verbose output:
ssh -vvv [email protected]
-
Verify SSH agent (Termux):
eval $(ssh-agent) ssh-add ~/.ssh/id_ed25519 ssh-add -l # Should show your key
-
Restart SSH service (Mac):
sudo launchctl stop com.openssh.sshd sudo launchctl start com.openssh.sshd
-
Check file permissions (Mac):
ls -ld ~ ls -la ~/.ssh/ # Home directory should not be writable by others # .ssh should be 700, authorized_keys should be 600
-
Specify identity file explicitly:
ssh -i ~/.ssh/id_ed25519 [email protected]
- Verify SSH is enabled in Mac System Settings
- Check firewall settings:
- System Settings → Network → Firewall
- Ensure "Block all incoming connections" is OFF
- Verify both devices are on Meshnet
- Ensure both devices have NordVPN running
- Check Meshnet is enabled on both
- Verify devices are linked in Meshnet
- Try using local IP first to test
- Check username is correct
- Verify user has SSH access in Mac settings
- Check authorized_keys has correct content
- Look for ACL issues:
ls -ld ~ | grep +
- ED25519 is recommended over RSA
- Consider using a passphrase for the private key
- Only allow specific users
- Consider changing default SSH port
- Use fail2ban or similar for brute-force protection
# Mac
brew update && brew upgrade
# Termux
pkg update && pkg upgrade# Check SSH logs on Mac
log show --predicate 'process == "sshd"' --last 1hOnce key-based auth works, edit /etc/ssh/sshd_config:
PasswordAuthentication no
PubkeyAuthentication yes
- Username: sandeepvishnu
- Hostname: Personal-MacBook-Pro.local
- Local IP: 192.168.4.52
- Mesh name: personal-macbook-pro.nord
# Generate SSH key (Termux)
ssh-keygen -t ed25519
# Copy key to Mac
ssh-copy-id user@host
# Connect with verbose output
ssh -v user@host
# Connect via Meshnet
ssh [email protected]
# List active SSH sessions (Mac)
who | grep pts