Some of the developers from Nautilus project team have asked for SFTP access to at least one of the app server in Stratos DC. After going through the requirements, the system admins team has decided to configure the SFTP server on App Server 1 server in Stratos Datacenter. Please configure it as per the following instructions:
a. Create a SFTP user rose and set its password to ksH85UJjhb. There is already a group called ftp, you can utilise the same.
b. Password authentication should be enabled for this user.
c. SFTP user should only be allowed to make SFTP connections.
Step 1: Log in to App Server 1
From the jump host, SSH into stapp01 as tony:
# Login: user=tony | password=Ir0nM@n | host=stapp01 (10.244.234.203)
ssh tony@stapp01
Output:
thor@jump-host ~$ ssh tony@stapp01
The authenticity of host 'stapp01 (10.244.234.203)' can't be established.
ED25519 key fingerprint is SHA256:ottNiKFuV3XUMmGi1d08ZjUQOqrZac3botOUEDcbLP4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'stapp01' (ED25519) to the list of known hosts.
tony@stapp01's password:
[tony@stapp01 ~]$
Step 2: Switch to root
All configuration changes require root privileges:
# Login: user=tony | password=Ir0nM@n | sudo to root (same password)
sudo -i
Output:
[tony@stapp01 ~]$ sudo -i
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.
[sudo] password for tony:
[root@stapp01 ~]#
Step 3: Create the SFTP user rose
Create the user with the ftp group and set the shell to /sbin/nologin so shell login is impossible:
# Login: root@stapp01 | Create user rose, group=ftp, no shell
useradd -G ftp -s /sbin/nologin rose
đĄ Why
/sbin/nologin? It prevents the user from getting an interactive shell. Combined withForceCommand internal-sftp(Step 5), the user can only use SFTP.
Set the password to exactly ksH85UJjhb:
# Login: root@stapp01 | Set password to ksH85UJjhb (twice)
passwd rose
When prompted, enter ksH85UJjhb twice:
Changing password for user rose.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
â ī¸ Note: Nothing is displayed on screen while typing the password â that's normal Linux behavior. Type it carefully and press Enter, then repeat.
Step 4: Verify the user and group membership
# Login: root@stapp01 | Verify user exists, group=ftp
id rose
Output:
uid=1001(rose) gid=1001(rose) groups=1001(rose),50(ftp)
â
groups=...,50(ftp) confirms rose is in the ftp group.
Confirm the shell is nologin:
# Login: root@stapp01 | Confirm shell is nologin
getent passwd rose
Output:
rose:x:1001:1001::/home/rose:/sbin/nologin
â
/sbin/nologin confirms no shell access.
Step 5: Configure SSH to force user rose to only use SFTP
Check whether a Match block already exists for rose:
# Login: root@stapp01 | Check for existing Match block
grep -A2 "Match User rose" /etc/ssh/sshd_config
(No output in this run â the block doesn't exist yet, so we add it.)
Edit the SSH daemon configuration:
# Login: root@stapp01 | Add SFTP-only Match block at end of file
vi /etc/ssh/sshd_config
Add the following block at the end of the file:
Match User rose
ForceCommand internal-sftp
PasswordAuthentication yes
đĄ What each line does:
Match User roseâ applies the following rules only to userrose.ForceCommand internal-sftpâ forces every connection to use SFTP, blocking shell/SSH commands.PasswordAuthentication yesâ explicitly enables password-based authentication for this user (requirement b).
Step 6: Validate and restart SSH
Test the configuration before restarting:
# Login: root@stapp01 | Validate SSH config
sshd -t
(No output = syntax is valid.)
Restart the SSH service to apply changes:
# Login: root@stapp01 | Restart SSH to apply the Match block
systemctl restart sshd
Step 7: Verify SFTP access works
Test from the server itself (or the jump host):
# Login: user=rose | password=ksH85UJjhb | test SFTP connection
sftp rose@stapp01
Enter password ksH85UJjhb when prompted:
The authenticity of host 'stapp01 (10.244.234.203)' can't be established.
ED25519 key fingerprint is SHA256:ottNiKFuV3XUMmGi1d08ZjUQOqrZac3botOUEDcbLP4.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'stapp01' (ED25519) to the list of known hosts.
rose@stapp01's password:
Connected to stapp01.
sftp>
â
SFTP login successful â the sftp> prompt confirms rose can connect via SFTP.
âšī¸ In the transcript, a typed
ssh rose@stapp01inside thesftp>prompt returnedInvalid command.â that's expected. Thesftp>prompt is an SFTP shell, not a regular shell;sshis not an SFTP command. This actually confirms the user is locked into SFTP mode.
Step 8: Verify SSH shell login is blocked
From a separate terminal (or after exiting SFTP with exit), attempt a normal SSH login:
# Login: user=rose | password=ksH85UJjhb | should be REJECTED
ssh rose@stapp01
Expected result â connection accepted for auth but shell denied:
rose@stapp01's password:
This service allows sftp connections only.
Connection to stapp01 closed.
â
The ForceCommand internal-sftp directive blocks the shell, fulfilling requirement c (SFTP-only access).
â Final Summary
| Requirement | Result | Proof |
|---|---|---|
User rose created, in ftp group, password set |
â Done |
id rose â groups=...,50(ftp)
|
Password authentication enabled for rose
|
â Done |
PasswordAuthentication yes in Match block |
| SFTP-only access (no shell) | â Done | SFTP connects; SSH shell rejected with "This service allows sftp connections only." |
đ Key Takeaways
-
useradd -G ftp -s /sbin/nologin roseâ adds the user to theftpgroup and blocks shell login in one step. -
passwd roseâ sets the password; nothing is echoed on screen while typing (normal behavior). -
Match User <name>block in/etc/ssh/sshd_configlets you apply per-user SSH rules without affecting other users. -
ForceCommand internal-sftpis the critical directive that restricts a user to SFTP only â no shell, no SCP, no SSH commands. -
PasswordAuthentication yesinside the Match block explicitly satisfies the "password auth enabled" requirement. -
sshd -tvalidates the config before restart â always run it to catch syntax errors beforesystemctl restart sshd. -
/sbin/nologin+ForceCommand internal-sftptogether provide defense in depth: even if the Match block were removed, the nologin shell would still block interactive login.
Top comments (0)