<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https:///index.php?action=history&amp;feed=atom&amp;title=Sftp_server</id>
	<title>Sftp server - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https:///index.php?action=history&amp;feed=atom&amp;title=Sftp_server"/>
	<link rel="alternate" type="text/html" href=""/>
	<updated>2026-04-07T09:39:38Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id></id>
		<title>Gr0x0rd: Created page with &quot;References:  https://qiita.com/alokrawat050/items/fcbf86aaf7de34aacba5  https://askubuntu.com/questions/324503/2-sshd-configurations-1-for-internal-and-1-external  Ensure the...&quot;</title>
		<link rel="alternate" type="text/html" href=""/>
		<updated>2023-02-03T06:09:44Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;References:  https://qiita.com/alokrawat050/items/fcbf86aaf7de34aacba5  https://askubuntu.com/questions/324503/2-sshd-configurations-1-for-internal-and-1-external  Ensure the...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;References:&lt;br /&gt;
&lt;br /&gt;
https://qiita.com/alokrawat050/items/fcbf86aaf7de34aacba5&lt;br /&gt;
&lt;br /&gt;
https://askubuntu.com/questions/324503/2-sshd-configurations-1-for-internal-and-1-external&lt;br /&gt;
&lt;br /&gt;
Ensure the openssh-server and ssh packages are installed.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Add the desired user account. Configure the password and store it in the vault.&lt;br /&gt;
 $ sudo adduser sftp_user&lt;br /&gt;
Create the file transfer directory if it is needed.&lt;br /&gt;
 $ sudo mkdir -p /var/www/testsite/data&lt;br /&gt;
Set the directory permissions for the root folder.&lt;br /&gt;
 $ sudo chown root:root /var/www/testsite&lt;br /&gt;
 $ sudo chmod 755 /var/www/testsite&lt;br /&gt;
Set the directory permissions for the data fodler.&lt;br /&gt;
 $ sudo chown sftp_user:sftp_user /var/www/testsite/data&lt;br /&gt;
Create a second ssh instance.&lt;br /&gt;
 $ sudo cp /etc/ssh/sshd_config /etc/ssh/sftp_config&lt;br /&gt;
 $ sudo cp /lib/systemd/system/ssh.service /lib/systemd/system/sftp.service&lt;br /&gt;
Configure the new instance to read the new config file.&lt;br /&gt;
 $ sudo nano /lib/systemd/system/sftp.service&lt;br /&gt;
Ensure the following configuration: &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS -f /etc/ssh/sftp_config&lt;br /&gt;
...&lt;br /&gt;
Alias=sftp.service&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Make the necessary changes to the config file. &lt;br /&gt;
 $ sudo nano /etc/ssh/sftp_config&lt;br /&gt;
Set the port as appropriate. Example for password auth:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Port &amp;lt;your_port_number&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
Match User sftp_user&lt;br /&gt;
ForceCommand internal-sftp&lt;br /&gt;
PasswordAuthentication yes&lt;br /&gt;
ChrootDirectory /var/www/testsite&lt;br /&gt;
PermitTunnel no&lt;br /&gt;
AllowAgentForwarding no&lt;br /&gt;
AllowTcpForwarding no&lt;br /&gt;
X11Forwarding no&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Example for shared key auth:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Port &amp;lt;your_port_number&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
Match User sftp_user&lt;br /&gt;
ForceCommand internal-sftp&lt;br /&gt;
RSAAuthentication yes&lt;br /&gt;
PubkeyAuthentication yes&lt;br /&gt;
AuthorizedKeysFile .ssh/authorized_keys&lt;br /&gt;
PasswordAuthentication no&lt;br /&gt;
ChrootDirectory /var/www/testsite&lt;br /&gt;
PermitTunnel no&lt;br /&gt;
AllowAgentForwarding no&lt;br /&gt;
AllowTcpForwarding no&lt;br /&gt;
X11Forwarding no&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Enable and start the service.&lt;br /&gt;
 $ sudo systemctl enable sftp.service&lt;br /&gt;
 $ sudo systemctl start sftp.service&lt;br /&gt;
Optional: use telnet to confirm the service is now running on the desired port.&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
 $ sudo nano /etc/csf/csf.conf&lt;br /&gt;
Ensure that the port you have added for the service and configured above are present in the TCP_IN/TCP_OUT sections of the file. When done restart the firewall&lt;br /&gt;
 $ sudo systemctl restart csf&lt;br /&gt;
 $ sudo csf -r&lt;br /&gt;
 $ sudo systemctl restart lfd&lt;br /&gt;
&amp;lt;br&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
Use the [[Ssh_keypair_setup]] documentation to set up a keypair for the sftp_user account. Make sure the user account is the owner of the .ssh folder and its perms are set to 700. Also make sure the account is the owner of the authorized_keys file, and the perms are set to 600.&lt;/div&gt;</summary>
		<author><name>Gr0x0rd</name></author>
	</entry>
</feed>