First of all, if I do a simple ssh [email protected] "cat backup.tar" > backup.tar this is not happening! So, there is something else converting it which I don't know.
I have the requirement to provide a backup of the current state of the system without giving access to the server. What I have done is the following:
- Create a new user. Let's call him
username - Allow only access via ssh-key
- Put the keys into the
authorized-keys - Change the command / shell in
/etc/passwdto a custom script forusername - Custom script gets the data by doing a database dump and copy some files and eventually creates a tar archive to the
stdout - Make sure that there is no additional output to
stdout.
To get the data you need to do: ssh [email protected] > backup.tar.
Now, nearly everything is working fine except that the line ending is changed. The tar gets bigger and I can see that every line has the dos line ending with a ^M symbol. If I force dos2unix on the binary tar file the file matches the file on the server.
Why is this happening and what is changing the line ending?
I even simplified it to the following: The script on the server for username linked in /etc/passwd just make a cat .viminfo and the line endings are still transferred wrong when using the above ssh command to login as username and redirect the output to a file on my local machine.