Softwareā±ļø 3 min readšŸ“… 2026-06-15

How to Fix: scp error: not a regular file

SCP error not a regular file fix for copying directory to remote machine.

Quick Answer: The issue is caused by the trailing whitespace in the source path. Remove the whitespace from /run/media/orcacomputers/DataCabinet/fileBackups/centos6-root/etc/httpd/conf.d​ to fix the error.

The 'scp error: not a regular file' issue affects users who attempt to copy directories using the scp command. This error occurs when the directory being copied is not a regular file, causing the scp command to fail.

This error can be frustrating for system administrators and developers who rely on scp for file transfers. The good news is that this issue can be resolved with a few simple steps.

šŸ’” Why You Are Getting This Error

  • The primary reason for this error is that the scp command does not support copying directories by default. When you try to copy a directory using scp, it attempts to copy each individual file within the directory, which can lead to errors if the directory contains non-file items like subdirectories or special files.
  • An alternative reason for this error could be due to issues with permissions or access rights on the local machine or remote server. If the user running the scp command does not have the necessary permissions to read or write files in the specified directory, the command will fail.

šŸ”§ Proven Troubleshooting Steps

Use the -r option with scp

  1. Step 1: To resolve this issue, you can use the -r option with scp. The -r option tells scp to copy directories recursively, allowing it to handle directory contents correctly.
  2. Step 2: To use the -r option, simply add the -r flag before the source directory path in your scp command. For example: `sudo scp -r /run/media/orcacomputers/DataCabinet/fileBackups/centos6-root/etc/httpd/conf.d/ :root@ip/etc/httpd/conf.d/`
  3. Step 3: By using the -r option, you can ensure that all files and subdirectories within the specified directory are copied correctly to the remote server.

Use an alternative file transfer tool

  1. Step 1: Alternatively, you can use other file transfer tools like rsync or sftp, which support copying directories by default.
  2. Step 2: To use rsync or sftp, you will need to install the corresponding package on your local machine and configure it to connect to the remote server. For example: `rsync -avz /run/media/orcacomputers/DataCabinet/fileBackups/centos6-root/etc/httpd/conf.d/ root@ip:/etc/httpd/conf.d/`

✨ Wrapping Up

By following these steps, you should be able to resolve the 'scp error: not a regular file' issue and successfully copy directories from your local machine to a remote server.

Did this fix your problem?

If not, try searching for specific error codes.

šŸ” Search Error Database

ā“ Frequently Asked Questions