How to SSH into your Ubuntu machine from macOS as superuser

发布于:2025-07-20 ⋅ 阅读:(15) ⋅ 点赞:(0)

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:

🧭 Step 1: Enable SSH on Ubuntu

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

💻 Step 2: Find Ubuntu’s IP Address

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).

🛜 Step 3: SSH from macOS Terminal

On your Mac, open Terminal and run:

ssh username@192.168.2.7

Replace username with your Ubuntu account name and 192.168.2.7 with your actual IP.

🔐 Step 4: Elevate to Superuser

Once connected, run:

sudo -i

This gives you a root shell, assuming your user has sudo privileges.


🔍 To check if the SSH server is running on your Ubuntu system:

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.


网站公告

今日签到

点亮在社区的每一天
去签到