Installation of OpenSSH SFTP Server on macOS

OpenSSH SFTP Server is a secure file transfer protocol software. It allows secure file transfer between computers over an encrypted connection. This tutorial will explain how to install OpenSSH SFTP server on macOS using the homebrew package manager.

Prerequisites

Before installing OpenSSH SFTP server, please make sure that you have the following prerequisites:

Step 1: Update Homebrew Package Manager

In Terminal, type the following command to update the Homebrew package manager:

brew update

Step 2: Install OpenSSH

In Terminal, type the following command to install OpenSSH:

brew install openssh

Step 3: Configure SSH

Generate a New SSH Key

In Terminal, type the following command to generate a new SSH key:

ssh-keygen -t rsa

Follow the prompts to generate a new SSH key. By default, the key will be saved to the ~/.ssh directory.

Configure the SSH Configuration File

In Terminal, type the following command to open the SSH configuration file:

nano ~/.ssh/config

Add the following lines to the file:

Host *
    StrictHostKeyChecking no

This will disable strict host key checking.

Step 4: Configure SFTP

Create a New SFTP User

In Terminal, type the following command to create a new SFTP user:

sudo dscl . -create /Users/sftpuser
sudo dscl . -create /Users/sftpuser UserShell /usr/bin/false
sudo dscl . -create /Users/sftpuser RealName "SFTP User"
sudo dscl . -create /Users/sftpuser UniqueID 550
sudo dscl . -create /Users/sftpuser PrimaryGroupID 20
sudo dscl . -create /Users/sftpuser NFSHomeDirectory /Users/sftpuser
sudo dscl . -create /Users/sftpuser Password "*"

Configure SFTP

In Terminal, type the following command to open the SSH configuration file:

sudo nano /etc/ssh/sshd_config

Add the following lines to the file:

Match User sftpuser
  ChrootDirectory /Users/sftpuser
  ForceCommand internal-sftp
  AllowTcpForwarding no

This will configure SFTP for the newly created user.

Step 5: Start the OpenSSH SFTP Server

In Terminal, type the following command to start the OpenSSH SFTP server:

sudo launchctl load -w /System/Library/LaunchDaemons/ssh.plist

Conclusion

This tutorial has explained how to install OpenSSH SFTP server on macOS using the Homebrew package manager. By following these steps, you can set up secure file transfer protocol software for file transfer between computers over an encrypted connection.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!