sftp Carriage Return (^M) issue query

David Newall openssh at davidnewall.com
Thu Oct 1 14:48:41 AEST 2020


On 30/9/20 8:47 pm, Adair, Fraser wrote:
> We have migrated from RHEL 5.11 to RHEL 7.6 servers VMs (details of OpenSSH and SFTP version below)
>
> On the new (RHEL 7.6) server we are seeing ^M (Windows Carriage Return) characters appearing at the end of records of files transferred to new server.  This does not happen on the old server and we are using exactly the same file transfer, exactly the same files etc. just repointing from one server to the other.

As a guess, this sounds like you're transferring files by capturing 
output on an interactive session:

    $ ssh -t user at example.com cat datafile > local.datafile
    user at example.com's password:
    Connection to example.com closed.
    $ grep -q '^M' local.datafile && echo CR seen
    CR seen

Interactive sessions are subject to termcap/terminfo (although, 
obviously, not an issue for cat) and stty (e.g. stty onlcr).

I expect onlcr is commonly set as NL normally just moves the cursor down 
one line without moving it to the left of the screen; and CR normally 
just moves it to the left of the screen without advancing one line.



More information about the openssh-unix-dev mailing list