顯示具有 ssh 標籤的文章。 顯示所有文章
顯示具有 ssh 標籤的文章。 顯示所有文章

星期三, 2月 19, 2014

perl warning for setting locale failed

Can't set locale; make sure $LC_* and $LANG are correct!
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = "en_US:en",
LC_ALL = (unset),
LC_TIME = "zh_TW.utf8",
LC_MONETARY = "zh_TW.utf8",
LC_MEASUREMENT = "zh_TW.utf8",
LC_NUMERIC = "zh_TW.utf8",
LANG = "en_US.UTF-8"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_ALL to default locale: No such file or directory
上面這情形發生在透過 ssh 連到遠端機器執行與 perl 相關的程式時所發生的。
古哥說下面這地方有解法
http://stackoverflow.com/questions/2499794/how-can-i-fix-a-locale-warning-from-perl

原因在於 /etc/ssh/sshd_config 中有一行設定
# Allow client to pass locale environment variables
AcceptEnv LANG LC_*
這表示 ssh client 可以把它的 locale 環境變數傳給 ssh server。
但若 ssh server 中沒有安裝該 locale,就會出現上面這樣的訊息。

所以解法有幾個:
從 server 端解:
1. 安裝該 locale
$ sudo dpkg-reconfigure locales

2. ssh server 不要接收從 ssh client 傳來的 locale 環境變數
 # Allow client to pass locale environment variables
 # AcceptEnv LANG LC_*
從 client 解:
執行 ssh 時,強制設定 LANG 的環境變數為 C
$ LANG=C ssh user@remote_server

星期四, 3月 29, 2012

The Quick Way to Copy Public Key to Remote Machine's authorized_keys

Synopsis:
ssh-copy-id [-i [identity_file]] [user@]machine

ex: key-pair: richman and richman.pub
$ ssh-copy-id -i richman richman@remote_machine

NOTES:
If remote sshd has StrictModes set in its configuration, then the user's home, ~/.ssh, and ~/.ssh/authorized_keys need to have group writability disabled with
$ chmod go-w ~
$ chmod go-w ~/.ssh
$ chmod go-w ~/.ssh/authorized_keys

Reference:
man ssh-copy-id

authorized_keys permission on CentOS

The permission of ~/.ssh/authorized_keys must be set to 600 or 640 to let ssh login without password(with key) work.

Because /var/log/secure shows
sshd: Authentication refused: bad ownership or modes for file home/user/.ssh/authorized_keys