UbuntuやDebianでperl: warning: Setting locale failed.と怒られる問題を解決する

# sshでログインしてupgradeなどをすると出てくるしつこいエラーを直す


```
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = (unset),
        LC_ALL = (unset),
        LANG = "ja_JP.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
```

いろいろやったことをまとめると自分の場合は**原因はlocaleではなく**ssh_configの問題だったのでメモしておく

```
~> cat -n /etc/ssh/ssh_config
     1
     2  # This is the ssh client system-wide configuration file.  See
     3  # ssh_config(5) for more information.  This file provides defaults for
     4  # users, and the values can be changed in per-user configuration files
     5  # or on the command line.
     6
     7  # Configuration data is parsed as follows:
     8  #  1. command line options
     9  #  2. user-specific file
    10  #  3. system-wide file
    11  # Any configuration value is only changed the first time it is set.
    12  # Thus, host-specific definitions should be at the beginning of the
    13  # configuration file, and defaults at the end.
    14
    15  # Site-wide defaults for some commonly used options.  For a comprehensive
    16  # list of available options, their meanings and defaults, please see the
    17  # ssh_config(5) man page.
    18
    19  Host *
    20  #   ForwardAgent no
    21  #   ForwardX11 no
    22  #   ForwardX11Trusted yes
    23  #   RhostsRSAAuthentication no
    24  #   RSAAuthentication yes
    25  #   PasswordAuthentication yes
    26  #   HostbasedAuthentication no
    27  #   GSSAPIAuthentication no
    28  #   GSSAPIDelegateCredentials no
    29  #   GSSAPIKeyExchange no
    30  #   GSSAPITrustDNS no
    31  #   BatchMode no
    32  #   CheckHostIP yes
    33  #   AddressFamily any
    34  #   ConnectTimeout 0
    35  #   StrictHostKeyChecking ask
    36  #   IdentityFile ~/.ssh/identity
    37  #   IdentityFile ~/.ssh/id_rsa
    38  #   IdentityFile ~/.ssh/id_dsa
    39  #   Port 22
    40  #   Protocol 2,1
    41  #   Cipher 3des
    42  #   Ciphers aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128,aes128-cbc,3des-cbc
    43  #   MACs hmac-md5,hmac-sha1,umac-64@openssh.com,hmac-ripemd160
    44  #   EscapeChar ~
    45  #   Tunnel no
    46  #   TunnelDevice any:any
    47  #   PermitLocalCommand no
    48  #   VisualHostKey no
    49  #   ProxyCommand ssh -q -W %h:%p gateway.example.com
    50  #   RekeyLimit 1G 1h
    51      SendEnv LANG LC_*
    52      HashKnownHosts yes
    53      GSSAPIAuthentication yes
    54      GSSAPIDelegateCredentials no
```

となっているのでline51の__SendEnv LANG LC_*__をコメントアウトしたら直った。

```
~> sudo emacs /etc/ssh/ssh_config
~> grep -n --color=auto "LANG" /etc/ssh/ssh_config
53:#    SendEnv LANG LC_*
```

<br><br><br><br><br><br>
* * *
## localeの中身がなかったので一応やった
```
~> $LANG
~> sudo apt-fast install language-pack-ja-base
~> cat /etc/default/locale
~> cd /etc;sudo wget https://gist.githubusercontent.com/networkelements/de1110fd6f9c28aae304f7c9b65223e3/raw/0aa1c36df2d330fbe0ce7a3da77bd46218856bcf/locale
~> cat /etc/default/locale
~> sudo locale-gen ja_JP.UTF-8
~> sudo dpkg-reconfigure locales
```
* * *
### 参考
[apt-get で Setting locale failed が出た場合の対処 - the glue](http://sweep3092.hatenablog.com/entry/2014/12/15/105515)


[12.04 - How to solve LOCALE problem - Ask Ubuntu](http://askubuntu.com/questions/454260/how-to-solve-locale-problem)
[sshでログインした時、localeまわりでエラーが出た場合の対処法 - Qiita](http://qiita.com/kuronuko/items/ae84ffa8e61c054320fd)
[Ubuntu Serverの言語設定 - ゲンゾウ用ポストイット](http://genzouw.hatenablog.com/entry/20121205/1354716351)