Tag Archives: ssh

Setting locale failed on Mac OS X Mavericks

If you using Mac OS X (in my case, I’m using Mavericks), during SSH session, you may see this kind of error in your terminal:

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

To solve this, edit .bash_profile file in your host/local machine

sudo nano ~/.bash_profile

and add this line:

export LC_CTYPE=en_US.UTF-8
export LC_ALL=en_US.UTF-8

Credit to: Agile Faqs

Allow root login on FreeBSD

To allow root login via ssh on FreeBSD, edit sshd_config file:

sudo vi /etc/ssh/sshd_config

Find this line:

#PermitRootLogin no

and change it to:

PermitRootLogin yes

Now Restart sshd:

root@Freebsd10:~ # /etc/rc.d/sshd restart
Performing sanity check on sshd configuration.
Stopping sshd.
Waiting for PIDS: 1698.
Performing sanity check on sshd configuration.
Starting sshd.

SSH warning: unprotected private key file!

Recently I tried to playing around with Amazon EC2 server. After subscribing & setup my server, it will give you cert pem key to access the server instead of entering the key manually.

When I try to login, I got this error:
Permissions 0440 for ‘xxx.pem’ are too open.
It is recommended that your private key files are NOT accessible by others.
This private key will be ignored.
bad permissions: ignore key: xxx.pem

To fix this problem, just run this command:
chmod 0400 xxx.pem

The xxx.pem is your cert key file. After that try to login again. Should be fine. 🙂

ssh exchange identification: Connection closed by remote host

This error is caused by problems in your hosts.deny. If you installed all the recommended packages in Ubuntu, you’ll most likely have Denyhosts. If not, /etc/hosts.deny won’t exist, thus this tutorial will not apply to you.

First, ssh to your server via another IP

Open this file:

nano /etc/hosts.deny

Find your IP, and clear the line. It’ll look like:

sshd: [your ip]

You can put # symbol to comment it if you want.

Now lets save and exit out of nano, and restart SSH.

/etc/init.d/ssh restart

Done. Log out, and log back to verify.

If this problem will often repeat itself, so lets fix it so it won’t happen again.
Open this file:

nano /etc/hosts.allow

Scroll to the very bottom, and type this on a new line:

sshd: [your ip]

Save nano, and exit out. Then, restart SSH.

/etc/init.d/ssh restart

Voila, problem solved!

Write failed: Broken pipe issue on Mac OS X

If you ssh to your server using Terminal or iTerm, have you ever encountered this kind of problem?
If you do, here I give you a solution (maybe a solution. it works for me at the meantime) on how to solve this issue.

Open you terminal, and insert this command to your terminal and hit enter:

sudo sysctl -w net.inet.tcp.always_keepalive=9999