Adobe Introduces Powerful Generative AI Tools in Photoshop
Artificial Intelligence

Adobe Introduces Powerful Generative AI Tools in Photoshop Beta

by Veronica
June 1, 2023
2

Adobe Photoshop beta AI will take your creativity to the...

Read more
Adobe Photoshop's Generative Fill Feature

Exploring the Power of Adobe Photoshop’s Generative Fill Feature

June 1, 2023
ChatGPT app

The Easiest Way to Download ChatGPT App Free

June 1, 2023
Nvidia Unveils Futuristic Gaming Experience at Computex 2023

Nvidia Unveils Futuristic Gaming Experience at Computex 2023, Blending Gaming and AI

May 29, 2023
NVIDIA and Microsoft Partner to Accelerate AI

NVIDIA and Microsoft Partner to Accelerate AI

May 25, 2023
Soundstorm-Pytorch

Soundstorm-Pytorch: A Powerful Tool for Audio Generation

May 30, 2023
ChatGPT-Powered Bing to Dethrone Google

ChatGPT-Powered Bing to Dethrone Google: The Rise of AI in Search Engines

February 15, 2023
Dute AI for Google Workspace

Revolutionizing Collaboration: How Duet AI for Google Workspace is Changing the Game

May 12, 2023
5 Surprising Facts about ChatGPT

5 Surprising Facts about ChatGPT you Never Heard

February 4, 2023
InternGPT A New Way to Interact with ChatGPT

InternGPT: A New Way to Interact with ChatGPT

May 27, 2023
AutoGPT vs other AI

What Is Auto-GPT, and How Does It Differ from Other AI Tools?

May 4, 2023
Cloudbooklet
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS
No Result
View All Result
Cloudbooklet
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS
No Result
View All Result
Cloudbooklet
No Result
View All Result
Home Linux

Setup SFTP and Prevent SSH on Ubuntu 20.04

by Cloudbooklet
May 23, 2023
in Linux
Reading Time: 5 mins read
Setup SFTP and Prevent SSH on Ubuntu 20.04
Share on FacebookShare on TwitterShare on WhatsAppShare on Telegram

Setup SFTP and Prevent SSH on Ubuntu 20.04. SFTP (Secure File transfer Protocol), a secure way to transfer files to servers using encrypted SSH connections. All servers with SSH will have SFTP enabled by default.

In this guide you are going to learn how to limit SFTP access to a directory for a particular user and prevent SSH access.

You might also like

Best PHP-FPM Configuration - Easy and Simple Calculation

Best PHP-FPM Configuration – Easy and Simple Calculation

June 1, 2023
How to Use ChatGPT in Linux Terminal

How to Use ChatGPT in Linux Terminal

May 19, 2023

This setup is tested on a virtual machine running Ubuntu 20.04 OS. So this tutorial should work on any severs with Ubuntu.

Prerequisites

SSH access to server with sudo privileges.

Step 1: Create New user

Create a new user who has SFTP access to perform certain actions on a particular directory.

sudo adduser username

You will be prompted to setup a password and other optional details which you can setup or ignore it.

If you wish to use SSH keys based login, check how to setup SSH access on your Ubuntu.

Step 2: Setup SFTP access

To setup SFTP access you need to configure correct directory permissions the parent directory of the new directory you are about to create should be owned by root and not by any other users.

For example, if you are going to create a directory named /sftp/folder, the sftp directory should be owned by root and the folder directory should be owned by the particular user who is accessing it.

Create directories.

sudo mkdir -p /sftp/folder

Configure correct permissions.

sudo chmod 755 /sftp
sudo chown root:root /sftp
sudo chmod -R 755 /sftp/folder
sudo chown username:username /sftp/folder

Step 3: Prevent SSH access and Restrict SFTP Access

Now we can modify SSH configuration to prevent SSH access for the user and restrict the user to access only the particular directory.

Edit your SSH configuration file.

sudo nano /etc/ssh/sshd_config

Add the following to the end of the file.

Match User username
  ForceCommand internal-sftp
  PasswordAuthentication yes
  ChrootDirectory /sftp
  PermitTunnel no
  AllowAgentForwarding no
  AllowTcpForwarding no
  X11Forwarding no
  • Match User tells the SSH server to apply the following commands only to the specified user.
  • ForceCommand internal-sftp forces the SSH server to run the SFTP server upon login and prevent SSH access.
  • PasswordAuthentication yes allows password authentication for this user. If you use SSH keys based login you can prevent password based authentication by setting the value to no.
  • ChrootDirectory /sftp ensures that the user will not be allowed access to anything beyond the /sftp directory.
  • AllowAgentForwarding no, AllowTcpForwarding no, and X11Forwarding no disables port forwarding, tunneling, and X11 forwarding, respectively.

Hit CTRL + X followed by Y and then ENTER to save and exit the file.

Now the configurations are in place which allows only SFTP access and prevents SSH login for the user.

Restart SSH service for the changes to take effect.

sudo systemctl restart sshd

For more details on configuring access for multiple usernames, you can follow this Chroot setup guide.

Step 4: Verify SFTP setup

Try loging in to the server using your SFTP details with SSH command. You will be denied access to SSH.

ssh [email protected]_ip

You will receive an output similar to the one below.

Output
This service allows sftp connections only.
Connection to server_ip closed.

Now verify using sftp command.

sftp [email protected]_ip

Now you should be logged in to the server and have access to the directory you have configured earlier.

Output
Connected to server_ip
sftp>

Use the ls command to list the directories you will see the directory named folder you have created and configured permissions.

sftp> ls
Output
folder

Conclusion

Now you have learned how to setup SFTP and prevent SSH access to user over a specific directory.

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Tags: UbuntuUbuntu 20.04
ShareTweetSendShare
Cloudbooklet

Cloudbooklet

Help us grow and support our blog! Your contribution can make a real difference in providing valuable content to our readers. Join us in our journey by supporting our blog today!
Buy me a Coffee

Related Posts

Install WordPress with Docker Compose, Nginx, Apache with SSL

WordPress Deployment Made Easy: Docker Compose, Nginx, Apache, SSL Setup Guide

May 20, 2023
How to Install WordPress on Docker

How to Install WordPress on Docker for Windows, macOS, and Linux

May 20, 2023
How to install python on Ubuntu

How to Install Python on Ubuntu 22.04?

May 31, 2023
what's new in node.js 20

What’s new in Node.js 20?

April 23, 2023

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I agree to the Terms & Conditions and Privacy Policy.

  • Trending
  • Comments
  • Latest
DragGAN The AI-Powered Image Editing Tool

DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

May 30, 2023
DragGAN AI editing Tool Install and Use DragGAN Photo Editor

DragGAN AI editing Tool Install and Use DragGAN Photo Editor

May 27, 2023
Bard API key

Everything You Need to Know About Google’s Bard API Key

May 20, 2023
Install PHP 8.1 on Ubuntu

How to Install or Upgrade PHP 8.1 on Ubuntu 20.04

May 17, 2023
DragGAN The AI-Powered Image Editing Tool

DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

79
Upgrade PHP version to PHP 7.4 on Ubuntu

Upgrade PHP version to PHP 7.4 on Ubuntu

28
Install Odoo 13 on Ubuntu 18.04 with Nginx - Google Cloud

Install Odoo 13 on Ubuntu 18.04 with Nginx – Google Cloud

25
Best Performance WordPress with Google Cloud CDN and Load Balancing

Best Performance WordPress with Google Cloud CDN and Load Balancing

23
Best PHP-FPM Configuration - Easy and Simple Calculation

Best PHP-FPM Configuration – Easy and Simple Calculation

June 1, 2023
ChatGPT Shared Links

ChatGPT Shared Links: A New Way to Share Your Conversations

June 1, 2023
Deepfake

Deepfake: The Rise of Synthetic Media

June 1, 2023
How to Setup SSH Keys on Ubuntu

How to Setup SSH Keys on Ubuntu 20.04

May 31, 2023

Popular Articles

  • DragGAN The AI-Powered Image Editing Tool

    DragGAN: The AI-Powered Image Editing Tool That Makes Editing Images Easy

    1513 shares
    Share 605 Tweet 378
  • DragGAN AI editing Tool Install and Use DragGAN Photo Editor

    396 shares
    Share 158 Tweet 99
  • Auto-Photoshop-Stable Diffusion-Plugin: A New Way to Create AI-Generated Images in Photoshop

    71 shares
    Share 28 Tweet 18
  • InternGPT: A New Way to Interact with ChatGPT

    56 shares
    Share 22 Tweet 14
  • Microsoft research Reveals GPT-4 AI Shows Promising Signs of Common Sense and Human-Like Reasoning

    98 shares
    Share 39 Tweet 25
Latest Technology Trends in Artificial Intelligence and Machine Learning with Cloudbooklet

Welcome to our technology blog, where we explore the latest advancements in the field of artificial intelligence (AI) and how they are revolutionizing cloud computing. In this blog, we dive into the powerful capabilities of cloud platforms like Google Cloud Platform (GCP), Amazon Web Services (AWS), and Microsoft Azure, and how they are accelerating the adoption and deployment of AI solutions across various industries. Join us on this exciting journey as we explore the endless possibilities of AI and cloud computing.

  • About
  • Contact
  • Disclaimer
  • Privacy Policy

Cloudbooklet © 2023 All rights reserved.

No Result
View All Result
  • News
  • Artificial Intelligence
  • Linux
  • Google Cloud
  • AWS

Cloudbooklet © 2023 All rights reserved.

This website uses cookies. By continuing to use this website you are giving consent to cookies being used. Visit our Privacy and Cookie Policy.