How to SSH into your Ubuntu machine from macOS as superuser

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值