Unable to Submit Files via Rsync on Ubuntu VPS: Code 12 Error in Windows Terminal

Abstract: Resolve Rsync Code 12 errors on Ubuntu VPS by fixing destination permissions, ensuring target paths exist, and adjusting SSH flags like -T in Windows Terminal.

Created: 2026-10-23 by
Rsync Code 12 errors on Ubuntu VPS via Windows Terminal typically stem from permission mismatches, missing destination directories, or SSH configuration conflicts rather than network failures. This specific exit code indicates that the remote shell exited with an error during the transfer process. By verifying user permissions, ensuring target paths exist, and adjusting SSH command-line flags, you can resolve the issue and restore reliable file synchronization between your local Windows environment and the remote server.

Understanding Rsync Exit Code 12

The exit status 12 in Rsync is distinct from network timeouts (Code 30+) or authentication failures (Code 14). It specifically means that the remote shell command failed to execute properly. When you run Rsync over SSH, it essentially executes a command like rsync --server ... on the remote host. If the remote system cannot start this daemon, or if the user context lacks necessary privileges, the connection drops immediately with Code 12. Common triggers include incorrect path syntax, insufficient write permissions on the destination directory, or interference from SSH wrapper scripts.

Verifying Destination Permissions and Paths

The most frequent cause of Code 12 is attempting to write to a directory where the connecting user does not have write access. Before running the sync command, log into your Ubuntu VPS via SSH and check the ownership of the target folder. Use the ls -ld /path/to/destination command to view the current permissions. If the output shows that the directory is owned by root or another user, your non-root SSH session will fail silently during the Rsync handshake. To fix this, you must either change the ownership using sudo chown -R $USER:$USER /path/to/destination or adjust permissions with chmod. Additionally, ensure that the destination path exists. Rsync does not create intermediate directories automatically unless explicitly told to do so. If you are syncing to /var/www/html/new_folder and new_folder does not exist, Rsync may fail depending on the version and flags used. Always verify the absolute path on the remote side matches exactly what you intend. Setup SSH Connection with 3 Ubuntu Machines to Bypass a Firewall outlines foundational connectivity steps that ensure your SSH tunnel is stable before layering file transfer protocols on top. A stable SSH baseline reduces variables when diagnosing application-layer errors like Code 12.

Adjusting SSH Command-Line Flags

Windows Terminal often invokes SSH with different default behaviors than traditional PuTTY sessions, particularly regarding terminal allocation and escape characters. The presence of pseudo-terminal allocation can sometimes interfere with Rsync's ability to spawn its server process cleanly. You can mitigate this by adding the -T flag to disable pseudo-terminal allocation in your SSH command. For example, use ssh -T user@host as part of your Rsync call. Another critical adjustment involves handling escape characters. If your SSH config includes options that alter how commands are parsed, Rsync might misinterpret its own arguments. Ensure that your ~/.ssh/config file on Windows does not contain aggressive compression or cipher settings that conflict with the Ubuntu server's expectations. Try stripping down your SSH invocation to bare essentials: rsync -avz -e "ssh -T" source/ user@remote:/dest/. This isolates whether the issue is with Rsync itself or the underlying SSH transport layer.

Checking for Wrapper Scripts and Aliases

On many Linux distributions, including Ubuntu, administrators sometimes set up SSH wrapper scripts or aliases in ~/.bashrc or /etc/profile to enforce security policies or logging. These scripts often check for interactive terminals and may exit prematurely if they detect a non-interactive session, which is exactly what Rsync uses. If you see unexpected behavior, check if any startup scripts print messages or require input. You can test this by running a simple command via SSH: ssh user@host echo "test". If this command hangs or produces unexpected output, a wrapper script is likely interfering. To bypass this, you can force Rsync to use a login shell explicitly by modifying the -e option to -e "ssh -t", though this re-enables the pseudo-terminal issue mentioned earlier. A more robust solution is to comment out non-essential lines in .bashrc that are not guarded by if [ -z "$PS1" ], ensuring they only run for interactive shells. Can Ansible Reuse SSH Connection for Rsync? discusses advanced SSH multiplexing techniques that can improve performance, but also highlights how complex SSH configurations can introduce subtle failures. Reviewing these concepts helps in understanding how SSH handles multiple concurrent connections and session states.

Debugging with Verbose Output

When standard fixes fail, enable verbose debugging to pinpoint the exact moment of failure. Add the -v flag multiple times to your Rsync command, such as rsync -vvv. This increases the verbosity level, showing you the exact SSH command being executed and the response from the remote server. Look for lines indicating "sending incremental file list" followed immediately by an error. If the error occurs before any file listing appears, the issue is almost certainly related to authentication or remote shell execution. You can also capture the SSH debug logs by adding -vvv to the SSH command within the -e option: -e "ssh -vvv". This provides detailed information about key exchanges, channel openings, and any rejection reasons. Analyzing these logs often reveals missing public keys or rejected host keys that standard error messages hide.

Frequently Asked Questions

Why does Rsync work with SCP but fail with Rsync?

SCP operates as a single-file copy mechanism without spawning a persistent server daemon on the remote host. Rsync requires the remote system to execute an rsync --server process, which demands specific permissions and shell availability. If your user account has limited shell access or restricted commands, SCP may succeed while Rsync fails with Code 12 due to the inability to launch the required daemon.

How do I fix permission denied errors in Rsync?

You must ensure the destination directory is writable by the user initiating the transfer. Use sudo chown to change ownership to your SSH user or apply chmod 755 to grant read and execute permissions, and chmod 777 temporarily for testing write access. Avoid leaving directories world-writable in production environments; instead, use group permissions to manage access securely.

Does Windows Terminal handle SSH differently than PowerShell?

Windows Terminal acts as a container for various shells, including PowerShell and CMD. The difference lies in the underlying shell's environment variables and startup scripts. If you switch from PowerShell to CMD within Windows Terminal, the SSH command might behave differently due to varying PATH settings or alias definitions. Always test your Rsync command in the specific shell profile you intend to use for automation.

What causes Rsync to hang before displaying Code 12?

A hang usually indicates a network timeout or a firewall dropping packets after the initial handshake. Check if your VPS provider blocks high-port ranges used by Rsync's data transfer phase. Ensure that your SSH port (default 22) is open and that no intrusion detection systems are terminating long-running or repetitive connections. Verify connectivity using ping and telnet to rule out basic network issues.

Can I use Rsync over a non-standard SSH port?

Yes, you can specify a custom port using the -e flag combined with SSH options. Use -e "ssh -p 2222" to direct Rsync to connect through port 2222 instead of the default 22. Ensure that your Ubuntu VPS SSH daemon is configured to listen on that port in /etc/ssh/sshd_config and that the service has been restarted to apply changes.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More