Home > System Tutorial > LINUX > How To Install openSSH on NixOS

How To Install openSSH on NixOS

Jennifer Aniston
Release: 2025-03-19 09:46:09
Original
583 people have browsed it

This tutorial guides you through installing OpenSSH on NixOS, highlighting the differences from traditional Linux distributions.

Table of Contents

  • Introduction
  • Installing OpenSSH on NixOS
  • Verifying NixOS Version
  • Conclusion

Introduction

Unlike Debian or RHEL, NixOS utilizes a declarative and atomic package management system. Instead of directly installing packages, NixOS builds a new system configuration, ensuring reproducibility and enabling atomic upgrades and rollbacks. This approach avoids dependency conflicts and promotes a declarative configuration via /etc/nixos/configuration.nix.

Installing OpenSSH on NixOS

  1. Edit /etc/nixos/configuration.nix using a text editor (e.g., sudo nano /etc/nixos/configuration.nix).

  2. Uncomment or add the following line to enable the OpenSSH daemon:

    services.openssh.enable = true;
    Copy after login

    Optional customizations:

    # services.openssh.permitRootLogin = "no";
    # services.openssh.passwordAuthentication = true;
    # services.openssh.port = 22;
    # services.openssh.protocol = "2";
    Copy after login

    Remember to uncomment your chosen settings.

  3. Save and exit the editor.

  4. Rebuild the NixOS system: sudo nixos-rebuild switch

  5. After the rebuild, OpenSSH should be running. Verify with: sudo systemctl sshd status

    How To Install openSSH on NixOS

  6. Connect via SSH using an SSH client (e.g., ssh username@ip_address).

Verifying NixOS Version

Confirm your NixOS installation by checking the version: nixos-version

How To Install openSSH on NixOS

This displays the release version, codename, and Git revision.

Conclusion

This tutorial detailed OpenSSH installation on NixOS. While initially more complex, NixOS's method offers significant benefits in system reliability and integrity.

Further Reading:

  • Nix – A Powerful Package Manager
  • Getting Started With Nix Package Manager

The above is the detailed content of How To Install openSSH on NixOS. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template