- vừa được xem lúc

Setting Up Ubuntu VM on macOS with VirtualBox

0 0 2

Người đăng: Tran Light

Theo Viblo Asia

If you’re running macOS and want to experiment with Linux (for dev, learning, or server setup), VirtualBox is a free and reliable choice. Below, I’ll walk you through setting up Ubuntu 24.04 Server on VirtualBox, configuring networking, and enabling secure SSH access.


1. Install VirtualBox

  • Download VirtualBox from the official website.
  • Run the installer package and follow the steps to complete installation.

2. Create Your Ubuntu VM

  • Download the Ubuntu 24.04 Server ISO from Ubuntu’s site.

  • Open VirtualBox → New → create a new VM.

    • Give it a name (e.g., Ubuntu-24.04).
    • Point the ISO image to the downloaded Ubuntu ISO.
  • Click Finish to finalize the VM creation.


3. Configure the VM

Before booting up, tweak these settings in VirtualBox:

  • User Interface: set Visual stateScaled.

  • System:

    • Allocate CPU cores ≤ host CPU.
    • Allocate memory ≤ host memory.
  • Network:

    • Adapter 1 → Enabled
    • Attached to: Bridged Adapter
    • Name: en0: Wi-Fi (Mac’s Wi-Fi)
    • Promiscuous Mode: Deny
    • MAC Address: generate a new one
    • Cable Connected: ✅

4. Install and Enable SSH

Once the VM is up and running Ubuntu:

sudo apt install openssh-server

Back up the SSH config:

sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.original
sudo chmod a-w /etc/ssh/sshd_config.original

Generate host keys (if missing):

sudo ssh-keygen -A

Restart SSH:

sudo systemctl restart ssh.service

5. Connect with SSH Keys

From inside the VM, get your VM’s IP:

sudo apt install net-tools
ifconfig

Look for inet under enp0s3 → that’s your VM’s IP (e.g., 10.10.10.52).

From your Mac host, copy your public key:

ssh-copy-id -i ~/.ssh/your_public_key.pub <username>@<your-vm-ip>

Test login:

ssh <username>@<your-vm-ip>

Disable password login

Edit the config:

sudo nano /etc/ssh/sshd_config

Change:

PasswordAuthentication no

Restart SSH again:

sudo systemctl restart ssh.service

6. Assign a Static IP

To avoid your VM’s IP changing, configure it manually. Inside Ubuntu:

sudo nano /etc/netplan/static-ip-netcfg.yaml

Example:

network: version: 2 ethernets: enp0s3: dhcp4: no addresses: [10.10.10.52/24] # VM static IP gateway4: 10.10.10.1 nameservers: addresses: [8.8.8.8]

Apply config:

sudo netplan apply

✅ Done!

You now have:

  • Ubuntu 24.04 Server running in a VirtualBox VM on macOS
  • Bridged networking for direct access from your host
  • Secure, key-based SSH access
  • Static IP for stable connectivity

Perfect for dev environments, labs, or running lightweight services locally 🚀.

Bình luận

Bài viết tương tự

- vừa được xem lúc

Cài đặt server với Apache từ A-Z

I, Cần cài những gì bây giờ. Bạn là 1 newbie, và vào một ngày đẹp trời, bạn nhận 1 request từ "sếp" của bạn: "Tình hình là anh có 1 con server linux, chaỵ ubuntu 20, a cần em cài giúp anh môi trường đ

0 0 25

- vừa được xem lúc

Hỗ trợ xây dựng web bằng Wordpress

WordPress là một hệ thống quản lý nội dung (CMS) miễn phí và mã nguồn mở được phát triển bằng ngôn ngữ lập trình PHP và sử dụng cơ sở dữ liệu MySQL. Nó được sử dụng rộng rãi như một nền tảng để xây dự

0 0 89

- vừa được xem lúc

Một số mẫu hình thường thấy trong phép toán với ma trận ở những mạng neuron nhân tạo

Trước khi đến với bài viết, bạn đọc nên có kiến thức trước đó về một số góc nhìn khác nhau của phép nhân ma trận. Nếu chưa biết hoặc đã quên, bạn có thể tham khảo bài viết này: https://eli.

0 0 26

- vừa được xem lúc

Spring Data Elasticsearch - Tận dụng Elasticsearch trong ứng dụng Spring Boot

Elasticsearch là một hệ thống tìm kiếm và phân tích văn bản mã nguồn mở dựa trên Lucene. Nó được thiết kế để xử lý và tìm kiếm dữ liệu với tốc độ cực kỳ nhanh, giúp bạn tìm thấy thông tin cần thiết từ

0 0 35

- vừa được xem lúc

Bí Quyết Bảo Vệ Mạng: Ngăn Chặn Tấn Công DoS Từ Máy Chủ DHCP

Bạn có thể làm cho máy chủ DHCP không thể cấp địa chỉ IP cho thiết bị khác bằng cách triển khai một kiểu tấn công DoS, được biết đến với tên "tấn công làm cạn kiệt DHCP". Mình sẽ giải thích cho bạn cá

0 0 14

- vừa được xem lúc

Khởi tạo Jenkins Container trên Docker cơ bản (Phần 1)

Giới thiệu. .

0 0 9