How to force permission rights when sending files over SFTP

Solution Verified - Updated -

Issue

  • When uploading files using SFTP, permissions are always set to 644 and I want 664 instead

    $ sftp mysftpserver
    sftp> !ls -l myfile
    -rw-rw-r--. 1 rmetrich rmetrich 0 Dec 15 09:49 myfile
    sftp> put myfile
    Uploading myfile to /root/myfile
    myfile                                                                              100%    0     0.0KB/s   00:00    
    sftp> ls -l
    -rw-r--r--  1 rmetrich rmetrich 0 Dec 15 09:50 myfile
    
  • When uploading files using SFTP and preserving permissions, permissions are always set to source file's permissions and I want 664 instead

    $ sftp mysftpserver
    sftp> !ls -l myfile
    -rw-r--r--. 1 rmetrich rmetrich 0 Dec 15 09:49 myfile
    sftp> put -p myfile
    Uploading myfile to /root/myfile
    myfile                                                                              100%    0     0.0KB/s   00:00    
    sftp> ls -l
    -rw-r--r--  1 rmetrich rmetrich 0 Dec 15 09:50 myfile
    

Environment

  • Red Hat Enterprise Linux
  • sftp

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.