I have an Ubuntu server that is hosting some .png files using SFTP.

When I try to access those files from my Windows laptop, using FileZilla, or WinSCP, the files are not transferred successfully if Force UTF-8 is checked (Site ManagerCustom Charset):

The files are from VisualCron, running on a Windows Server, and while I've changed the encoding to UTF-8 in VisualCron, I'm unsure it's applying since that's the only place they could start being encoded differently.

Setup: enter image description here

  • OpenSSH sshd_config:
    # AcceptEnv LANG LC_*
    Subsystem sftp      = /usr/lib/openssh/sftp-server -l INFO
    Match Group         = sftp_users
    ChrootDirectory     = /ftproot/owners/%u
    ForceCommand        = internal-sftp

Note that I have commented out: AcceptEnv LANG LC_*. According to here, this means the server will not allow the client to pass locale environment variables. In this case, even if the Windows Server using VisualCron would send files using a 'wrong' encoding, the server should not accept it, and use UTF-8. Right?

  • Ubuntu server's locale settings:
    LANG                = en_US.UTF-8
    language            =
    LC_CTYPE            = "en_US.UTF-8"
    LC_NUMERIC          = "en_US.UTF-8"
    LC_TIME             = "en_US.UTF-8"
    LC_COLLATE          = "en_US.UTF-8"
    LC_MONETARY         = "en_US.UTF-8"
    LC_MESSAGES         = "en_US.UTF-8"
    LC_PAPER            = "en_US.UTF-8"
    LC_NAME             = "en_US.UTF-8"
    LC_ADDRESS          = "en_US.UTF-8"
    LC_TELEPHONE        = "en_US.UTF-8"
    LC_MEASUREMENT      = "en_US.UTF-8"
    LC_ALL              =
  • FileZilla:
    When using ISO-8859-15, files containing characters like è and é in the filename are transferred, but transferring files with Force UTF-8 enabled errors with:
    Response:  New directory is: "/tickets/"
    Command:   get "FILENAME containing Liège.png" "C:\test\FILENAME containing Liège.png"
      Error:   /tickets/FILENAME containing Liège.png: open for read: no such file or directory
      Error:   File transfer failed

Where can I see what encoding my SFTP server uses for file listings and how can I change it to UTF-8?

  • Although Linux is supposedly totally UTF-8 compatible for file-names, some applications are badly written. It would be simpler just to rename all the files so as to eliminate the accents, and is very simple to do.
    – harrymc
    Oct 26, 2020 at 15:57
  • png files are binary. UTF-8 is a text encoding, and is inappropriate for png. If you're forcing UTF-8 rules on png data, you should expect to get weird results. Oct 28, 2020 at 19:56

3 Answers 3


Preliminary remarks:

  • sftp must use UTF-8 as filename encoding (for example, see here as reference). However, there are clients and servers which don't follow that requirement and violate the specifications, which may be the cause of your problem.

  • You wrote: "Note that I have commented out: AcceptEnv LANG LC_*. According to here, this means the server will not allow the client to pass locale environment variables."

    There may be a misunderstanding regarding how this works and what it is good for. Whenever two machines communicate, they must use the same data formats. For example, suppose that VisualCron puts file names encoded as ISO 8859-1 into the byte stream it sends to the Ubuntu server, but you force the Ubuntu server to interpret the incoming (file name) byte stream as if it was encoded in UTF-8. That will not solve problems, but cause them.

Having said this:

I would at first try to find out where exactly the problem arises. I strongly assume that you have SSH access or even physical access (keyboard) to the Ubuntu server. Then

  • Check whether the locale en_US.UTF-8 is installed on the Ubuntu server at all. Please note that just setting the LC_ and LANG environment variables does not install a locale.

    Instead, you would install a locale during O/S installation or by something like dpkg-reconfigure locales (on debian - I don't know Ubuntu).

  • If using SSH, make sure that your SSH terminal software (e.g. Putty) uses the same encoding as the server.

  • Then, the most crucial step: Using your SSH terminal, manually create a file with a problematic name in the respective directory so that the sftp client on your Windows laptop can see it.

    For example, coming back to your question, you could create a file with name Liège.txt in your /tickets directory (touch /tickets/Liège.txt). Again using your SSH terminal, carefully double check that the file name appears correctly when you let Ubuntu list the files in that directory (ls -al /tickets).

  • Now use the sftp client on your Windows laptop and check whether it correctly downloads that newly created file.

    If this works, it means that your problem arises when VisualCron transfers the files to the Ubuntu server. If it does not work, the problem is between your Windows laptop and the Ubuntu server.

In both cases, there are tools which can help you analyze the situation.

For example, you can gain some insight from playing around with convmv, which can convert file names from one encoding to another. Notably, you could convert the encoding of your file names from UTF-8 to UTF-8. When you do that and you are sure that the file name already is encoded in UTF-8, it must not change during that conversion.

You might also want to have a look into chardet, which is a Python library which tries to guess the encoding of e.g. filenames. I am not a Python guy, so I can't help you with source code. According to the accepted answer to this question, you would have a line like chardet.detect(os.popen("ls yourfilename.txt").read()) in your Python script, which will output the most probable encoding along with a confidence rating.

To summarize:

  • Make sure that the file names on your Ubuntu server really are encoded in UTF-8, by following the steps shown above and using the tools mentioned above.

  • Once you are absolutely sure that the file names on your Ubuntu server are encoded in UTF-8, check whether your sftp client on your laptop can download them. If not, try other clients until it works.

  • If you have found that not all of the file names on the Ubuntu server are encoded in UTF-8, adjust the settings in VisualCron accordingly. I don't know VisualCron and thus can't help you with that.


SFTP is SSH in fact. So there are no configuration options on server side for SSH data sent/received.

The solution to this problem remains on the client side, so it will be WinSCP configuration and its compatibility to process non-standard characters.

It appears that UTF-8 is already standard encoding for WinSCP and server side.


My experience with files containing accented characters is that they travel very badly across the network. The working solutions that I saw were:

  • Zip or 7Zip the files at the source and unzip at the target. Use tar if conserving file permissions is required. The compression and the fact that only one file, the archive, is transferred, will improve the time of transfer by a lot.

  • Do the transfer using the same file-transfer utility on both sides that supports accented characters, for example using a file-share between two Linux or two Windows computers. Problems can however occur when transferring between Windows and Linux.

  • Rename all the files so that their names do not contain any accented characters. This is the best solution when moving files internationally.

For the last solution, you may easily find bash scripts to do this work, for example slugify.sh.

  • To retain files' permissions it would be advised to use tar, not 7z.
    – pbies
    Nov 3, 2020 at 14:51
  • @pbies: Right - added.
    – harrymc
    Nov 3, 2020 at 14:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .