Home
Random
Log in
Settings
About Apoyar Wiki
Disclaimers
Apoyar Wiki
Search
Editing
Creating an SFTP user for www server
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
Creating SFTP Access on Server ----------------------------------- Login to server, on which need to create SFTP access Go to below path and create folder, where need to upload data β’ cd /var/www β’ mkdir uploads Copy neal and nagios keyβs from Nagios server(nagios.apoyar) β’ scp neal nagios username@servername /home/neal/ move both keys to sshkeys folder β’ mv neal nagios /usr/share/sshkeys change nagios owner β’ chown nagios:nagios nagios change permission for neal and nagios β’ chmod 600 * Create simlink and restart sshd β’ ln -s /usr/share/sshkeys/nagios /home/nagios/.ssh/authorizedkeys β’ ln -s /usr/share/sshkeys/neal /home/neal/.ssh/authorizedkeys β’ systemctl restart sshd Create user apoyarsftp β’ useradd -m -d /var/www/uploads/ -G www-data /usr/sbin/nologin apoyarsftp Add user to www-data group β’ usrmod -a -G apoyarsftp www-data Go to home folder β’ cd /home/ β’ vi /etc/ssh/sshd.config Go to last & add below lines there Match User sftpuser ChrootDirectory folderpath X11Forwarding no AllowTcpForwarding no ForceCommand Internal-sftp edit username and folderpath sftpuser β apoyarsftp folderpath - /var/www/uploads/ save file :wq! β’ systemctl restart sshd Set password for apoyarsftp user β’ Passwd apoyarsftp Qwerty1! Change owner and permission for uploads folder β’ Cd /var/www β’ chown -R apoyarsftp apoyarsftp:apoyarsftp uploads/ β’ chown root:root uploads/ β’ chmod 755 uploads/ Create .ssh folder under uploads and change owner and permission for .ssh folder β’ cd uploads/ β’ mkdir .ssh β’ chmod -R 700 .ssh/ β’ chown βR apoyarsftp:apoyarsftp .ssh/ Go to below path and generate key β’ cd /usr/share/sshkeys β’ ssh-keygen Enter file name - ./apoyarsftp β’ mv apoyarsftp /home/neal β’ mv apoyarsftp.pub apoyarsftp Change owner and permission for apoyarsftp β’ chown apoyarsftp:apoyarsftp apoysrsftp β’ chmod 600 apoyarsftp Create simlink β’ ln βs /usr/share/sshkeys/apoyarsftp /var/www/uploads/.ssh/authorizedkeys Create subfolder under uploads folder and change owner for that folder β’ cd /var/www/uploads β’ mkdir private β’ chown βR apoyarsftp:apoyarsftp private Go to mercury.apoyar server and create new host under bleckmann β’ Name - sftp β’ IP address - Server IP adreess Click Add host Go to bleckmann server and add DNS record to hostfile β’ cd /home/neal β’ vi /etc/hosts And add below entry Server IP address sftp.bleckmann.apoyar Save the file (:wq1!) Now connect server try uploading files.
Summary:
Please note that all contributions to Apoyar Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Apoyar Wiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)