在 DigitalOcean 上以每月 4 美元的价格运行 OpenBSD
Run OpenBSD on DigitalOcean for $4/month

原始链接: https://nil.wallyjones.com/run-openbsd-on-digitalocean-for-4month/

作者近期将个人主页从 GitHub Pages 和 Cloudflare 等托管平台迁移到了运行于 DigitalOcean 上的 OpenBSD 服务器。出于对早期互联网“自力更生”精神的向往,作者详细介绍了如何以每月 4 美元的成本搭建 OpenBSD 实例。 具体流程包括:将 OpenBSD 的 `miniroot` 镜像作为自定义 ISO 上传至 DigitalOcean,创建一个小型 Droplet(云服务器),并通过网页控制台进行手动安装。指南涵盖了关键步骤,如网络配置、创建非 root 用户、禁用 root 远程登录 SSH,以及(可选的)启用全盘加密。通过精简掉 X Window System 和编译器等非必要组件,作者实现了一个精简、安全且高度定制化的 Web 服务器环境。 这种 DIY 方式被视为深入理解 Unix 系统的一种有益途径。对于希望获取完整技术细节的读者,作者建议参考《OpenBSD 手册》和常见问题解答(FAQ),以了解安装后的最佳实践,例如加强 SSH 安全设置。

最近的一场 Hacker News 讨论引发了关于在 DigitalOcean 上运行 OpenBSD 的争议,许多用户批评其 512MB 内存的 VPS 每月 4 美元的定价。 舆论普遍认为,虽然“大型”云服务商提供可靠性和 API,但用户往往可以通过 OVH、Hetzner 或 OpenBSD.amsterdam 等小型、专用或“低端”托管服务商,以更低的价格获得更好的配置(更多内存和 CPU)。 然而,评论者指出这其中存在权衡:廉价托管可能存在服务不稳定、超售或由缺乏经验的运营商管理的问题。一些用户警告称,小型服务商容易成为垃圾邮件发送者的目标,从而导致共享 IP 的信誉受损。 对于寻求替代方案的用户,建议包括: * **自托管:** 使用家用硬件并配合 Cloudflare Tunnels 或 Tailscale,从而无需依赖公共 VPS。 * **专用 VPS:** 使用 Vultr 或 OVH 等平台,这些平台常被认为是对 BSD 系统支持更好的替代方案。 * **免费层级:** 利用 Oracle Cloud 提供的免费资源。 归根结底,这一讨论反映了一种情绪转变:用户对“大云”的价格日益疲劳,转而寻求高度专业化、以社区为导向的托管服务,或是追求自主性更高的家庭实验室配置。
相关文章

原文

OpenBSD 7.9 Puffy dude

My homepage now runs on OpenBSD with httpd(8) and Let's Encrypt via acme-client(1). I previously hosted it on GitHub Pages and then eventually moved to Cloudflare Pages because both options were free and easy. Free and easy is cool, and I understand that writing software full-time leaves us wanting absolutely nothing to do with computers after we punch out, but lately I have been missing the do-it-yourself web that I grew up with. Some of my favorite times growing up included installing and configuring UNIX-based operating systems and spending hours trying to understand how computers worked. I even met one of my closest friends online through a FreeBSD UNIX shell account forum more than 20 years ago.

So, in that vein, I wanted to write something on how you can get up and running on OpenBSD with DigitalOcean for $4 a month. Well, really, it's $4.24 after tax but that's still pretty good!

Download OpenBSD

There are a few different options when it comes to downloading OpenBSD, but the quickest method is to grab the miniroot image.

curl -O -O https://cdn.openbsd.org/pub/OpenBSD/7.9/arm64/{miniroot79.img,SHA256}

Confirm that the checksum of the image is correct.

sha256sum -c --ignore-missing SHA256 miniroot79.img
miniroot79.img: OK

Sign Up for DigitalOcean and Upload miniroot79.img

Once you are signed up and logged in to DigitalOcean, go to Backups & Snapshots under the STORAGE section in the left-hand navigation. Click Upload an Image. Select the miniroot79.img file we downloaded earlier. Select a datacenter that makes sense for you. Select Other for the distribution (Hey, DigitalOcean, why no BSD distribution?). Give the custom image a name, something clever like "OpenBSD miniroot79". Finally, click the Add Custom Image button.

Note on Custom Images

DigitalOcean will charge you for hosting custom images. Make sure you come back to this page to delete the image after your server is up and running.

Upload custom image on DigitalOcean

Create a Droplet

Click Droplets under the COMPUTE section in the left-hand nav. We are going to create the basic droplet that includes 512MB memory, 1vCPU, 500GB transfer, and 10GB of disk space.

Select a datacenter region that makes sense for you.

Choose the miniroot79.img file we uploaded earlier under the Custom Images tab.

Select custom miniroot79.img file on DigitalOcean

Choose the Basic plan.

Select Basic / Regular SSD tier Droplet on DigitalOcean

Under the Authentication section add an SSH Key. DigitalOcean does not actually add this key but it is required to create the droplet. Follow the instructions on how to create and add an SSH key.

The rest of the options are up to you. Just a heads up, though, I have noticed that it won't let you create the droplet with IPv6 enabled. Finally, give your droplet a name and click Create Droplet.

Notice the total cost of $4.00/month... nice, dude.

Droplet creation summary showing $4.00/month on DigitalOcean

Install OpenBSD

Go to your newly created droplet and click the Web Console button at the top right. You will see a modal pop-up about updating the droplet console. Just click the Launch Recovery Console button.

Top of Droplet page showing Web Console button on DigitalOcean

This opens a new browser window that drops you into a console of the booted up miniroot79.img. Look at the blue on white text. Beautiful.

Web Console booting up miniroot79.img on DigitalOcean

Type i and press return.

For most of these questions we can go with the default option. Please select whatever makes sense for you, but I will try to walk you through a very basic setup. Just make sure you give your server a cool hostname.

Web Console showing OpenBSD installation options

  • Select the vio0 network interface.
  • Select autoconf for IPv4 and IPv6 addresses. Select [done] afterwards because we can configure other interfaces later.
  • Make sure you create a secure password for the root account.
  • We do want to start sshd(8) by default so we can SSH into the server after installation.
  • We do not expect to run the X Window System. This is a basic server, dude. Type no.
  • Don't change the default console to com0.
  • Create a non-root user for yourself. Make sure you create a secure password. Type in your username.
  • Do not allow root SSH login.
  • Select the time zone appropriate for you.
  • Select disk sd0 for the root disk. You can type ? if you wish to see the size of the disks.
  • If you want full disk encryption, select p to encrypt the disk with a passphrase.

Note on Full Disk Encryption

This will require you to log in to DigitalOcean and launch the web console on the droplet to type in the passphrase every time you reboot the server. As far as I know there is no fdesetup authrestart equivalent on OpenBSD so installing kernel patches that require a reboot involve a little more work. To me this isn't a big inconvenience. There may also be arguments around the security of typing into the web console.

Web Console showing OpenBSD disk setup

  • Use the (W)hole disk MBR.
  • Type in your secure passphrase for the full disk encryption.
  • Use the (A)uto layout.
  • No need to initialize sd1. Press return for [done].
  • Install the sets!
  • Use http.
  • We probably don't need a proxy but it's up to you.
  • Use ? to see a list of mirrors. Find the number for the mirror closest to the datacenter you selected for the droplet.
  • Press q to get out of the pager.
  • Type in the number of the mirror and press return. You should see the mirror in the brackets. Press return.
  • Use the default directory pub/OpenBSD/7.9/amd64.

Since this is going to be a bare-bones web server we can remove most of the sets. You can type in -x* to remove all of the X server sets. Let's also remove the game -gam* and compiler -com* sets too. This should leave us with bsd, bsd.rd, base79.tgz, and man79.tgz. Press return since we are done. You should see signatures verified for the sets as they download. After the sets install we can select [done].

Web Console showing sets installing and verifying

OpenBSD is now installed! Press return to reboot.

Web Console showing OpenBSD install has been successfully completed!

If you decided to use full disk encryption you will be prompted for the passphrase now. You should see the boot> prompt after successfully entering the passphrase. You can either press return to boot or wait for the system to boot automatically. From here you can either continue to use the Web Console or SSH into the server. I would recommend SSH since a terminal is a bit more comfy. Go to the droplet and copy the public IP address and SSH in! Make sure you use the non-root user we created during installation since we turned off root SSH login.

macOS Terminal with SSH connection to new OpenBSD Droplet server

You are now SSH'd into your lovely OpenBSD server running on DigitalOcean for $4/month.

Now would be a great time to head over to OpenBSD Handbook and read up on Post-Installation Configuration. I would also recommend taking a look at OpenBSD's FAQ Page. Finally, I would recommend copying your public SSH key to the server and turning off PasswordAuthentication as a bare minimum.

If you have any questions please do not hesitate to reach out to me, even if it's just to say hello! You can find my contact details on my cool homepage https://wallyjones.com, running on a cool OpenBSD server.

联系我们 contact @ memedata.com