To SSH into your Ubuntu machine from macOS as superuser, you’ll first connect as a regular user, then elevate privileges once logged in.
Here's how to do it step by step:
Make sure the SSH server is installed and running:
sudo apt update
sudo apt install openssh-server
sudo systemctl enable ssh
sudo systemctl start ssh
On Ubuntu, run:
ip a
Look for your active network interface (e.g., wlp3s0
or enp0s25
) and note the inet
IP address (e.g., 192.168.2.7
).
On your Mac, open Terminal and run:
ssh [email protected]
Replace username
with your Ubuntu account name and 192.168.2.7
with your actual IP.
Once connected, run:
sudo -i
This gives you a root shell, assuming your user has sudo privileges.
sudo systemctl status ssh
If it says Active: active (running)
, your SSH server is up and running.
If it says inactive
or failed
, it’s either stopped or encountered an error.
To start it:
sudo systemctl start ssh
To enable it at boot:
sudo systemctl enable ssh
⚠️ Warning: Direct root login over SSH is risky. It’s safer to log in as a regular user and use sudo
.