Here is a detailed response to the question about a home server running two SSH daemons, one for normal SSH connections with key authentication, and another for SFTP connections with password authentication.
Topic: Running Two SSH Daemons on a Home Server
Introduction
In this article, we will discuss the configuration of a home server running two SSH daemons. One daemon will handle normal SSH connections using key authentication, while the other will manage SFTP connections using password authentication on a different port (21).
SSH Daemon with Key Authentication
To set up the first SSH daemon, we will use OpenSSH, which is the most common implementation of the SSH protocol. To configure OpenSSH for key-based authentication, follow these steps:
- Install OpenSSH on your server if it isn't already installed.
sudo apt-get install openssh-server
- Create a new SSH key for the user who will be using the SFTP service.
ssh-keygen -t rsa -f /home/username/.ssh/id_rsa -P ""
- Configure SSH to use the new key for authentication.
Edit the SSH configuration file located at /etc/ssh/sshd_config and add the following lines:
# Allow users to log in using SSH keys
PubkeyAuthentication yes
# Disable password authentication
PasswordAuthentication no
- Restart the SSH daemon to apply the changes.
sudo systemctl restart ssh
SSH Daemon with SFTP Password Authentication
To set up the second SSH daemon for SFTP connections using password authentication, we will use the vsftpd package.
- Install
vsftpdon your server if it isn't already installed.
sudo apt-get install vsftpd
- Edit the
vsftpdconfiguration file located at/etc/vsftpd.confand add the following lines:
# Enable local user password authentication
local_enable=YES
# Disable anonymous access
anonymous_enable=NO
# Enable SFTP
sftp_enable=YES
# Set the SFTP port
listen=21
- Restart the
vsftpdservice to apply the changes.
sudo systemctl restart vsftpd
Summary
In this article, we discussed the configuration of a home server running two SSH daemons: one for normal SSH connections using key authentication, and another for SFTP connections using password authentication on port 21. This setup allows for secure file transfers while maintaining separate authentication methods for each service.
References