# How can I create a user account that is only allowed to use SCP for file transfers and cannot log in interactively via SSH?

**URL:** <https://hostingthreads.com/t/how-can-i-create-a-user-account-that-is-only-allowed-to-use-scp-for-file-transfers-and-cannot-log-in-interactively-via-ssh/45>\
**Category:** Linux Troubleshooting\
**Tags:** scp\
**Created:** [March 28, 2026, 12:02am UTC](https://hostingthreads.com/t/how-can-i-create-a-user-account-that-is-only-allowed-to-use-scp-for-file-transfers-and-cannot-log-in-interactively-via-ssh/45 "2026-03-28T00:02:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![computeman](https://hostingthreads.com/user_avatar/hostingthreads.com/computeman/32/29_2.png) [@computeman](https://hostingthreads.com/u/computeman)\
**Post date:** [March 28, 2026, 12:02am UTC](https://hostingthreads.com/t/how-can-i-create-a-user-account-that-is-only-allowed-to-use-scp-for-file-transfers-and-cannot-log-in-interactively-via-ssh/45/1 "2026-03-28T00:02:05Z")

</div>

Hey, We need to create a user account that is only allowed to use SCP for file transfers and cannot use SSH to log in or open a shell session.

Thanks 🙏

---

<div class="post-metadata">

**Author:** ![richardhaxel](https://hostingthreads.com/user_avatar/hostingthreads.com/richardhaxel/32/26_2.png) [@richardhaxel](https://hostingthreads.com/u/richardhaxel)\
**Post date:** [March 28, 2026, 12:14am UTC](https://hostingthreads.com/t/how-can-i-create-a-user-account-that-is-only-allowed-to-use-scp-for-file-transfers-and-cannot-log-in-interactively-via-ssh/45/2 "2026-03-28T00:14:06Z")

</div>

## Server Side

Add SCP onl user and group on te server as shown below.

```auto
# groupadd scponly
# useradd -G scponly -d /recv -M scpuser
# echo redhat | passwd --stdin scpuser

```

Create a dedicated directory specifically for use with SCP.

```auto
# mkdir /recv
# chmod 777 /recv

```

Add the configuration shown below to the sshd\_config file and then restart the SSH service.

```auto
# vim /etc/ssh/sshd_config 

```

```auto
Match Group scponly
        ForceCommand /usr/bin/scp -t /recv

```

```auto
# /etc/init.d/sshd restart

```

## Client Side

Create a test file and then use the SCP‑only user to copy that file to the server with scp.

```auto
# echo "testfile" > test.txt
# scp test.txt scpuser@ **Server** :/recv

```

Check whether the SCP‑only user is able to log in via SSH.

```auto
# ssh scpuser@ **Server**

```

As a result, you will see the following output:

```auto
scp: protocol error: unexpected <newline>
Connection to **Server** closed.

```

Verify the SCP‑transferred file on the server to confirm it was copied correctly.

```auto
# cat /recv/test.txt 
testfile

```

Have a good day. Let me know if you need more help.

👋
