ssh will not connect – Connection closed by remote host

Question:

When I try to connect with ssh I get an error such as “ssh_exchange_identification: Connection closed by remote host”. I know that ssh is enabled on my account. What is wrong?

Answer:

Usually these errors are caused when an attacker is scanning for badly configured servers with default usernames and passwords or easy to guess passwords. Our scripts detect and block such scans/attacks but there can be times during the attack when all connections are taken and the server refuses new connections. Your server is safe and such attacks/scans are part of the day-to-day life of servers on the internet. Usually you never notice the effects but in rare cases there can be disruptions.

A temporary work-around is to connect to ssh on port 23. Many of our servers run ssh on port 23 as well as port 22. You can try to connect to port 23 with:

ssh your_username@your_server.com -p 23

or change the port from 22 to 23 in your client.

Quick methods to move a website to a new host

Question:

How can I quickly clone my existing website to my new hosting account? I want to avoid copying all my files via ftp to my local computer and then re-uploading them – that would take a very long time on my slow internet connection.

Answer:

These command all require you to use the unix command shell but they are very fast ways to clone your website over. If you need help, send a message to support with the login information for your old host and we can do these commands for you.

To quickly pull your backup from your old host :

1. Make the backup on the old host

2. Move it somewhere in the public_html/www/”live” part of your site.

3. On your new server with us: wget http://server.oldhost.com/backup.tgz

4. remove the file from your old server. Don’t forget this step or you’ll have a copy of your site accessible to anyone who might happen to guess the name and location of it.

The second option is to use rsync to make a copy of your site and allow for updates without re-copying everything.

To clone with rsync, do the following: (again contact tech support if you need help!)

cd ~/
rsync -vaze ssh your_user@old_server.com:~/ .

this will copy all your files from the old host to your current directory.

The first run will copy everything over. When you run it over again, it will only copy over the changes. Useful if you want to move the site over, test it out and then do one final copy before going live (in case anything changed on the old server).

Linux Shell Host – What are my options?

phpwebhosting.com is a great choice for a Linux shell host. After you sign-up, put in a request for ssh and it will be enabled quickly (all new accounts need to be verified). All common unix shell tools are pre-installed and, best of all, the admins will install more for you on request. You also have compiler access so are free to do any custom installs into your account space.

Your account is a normal unix shell – no restricted shells here. subversion and git are both available for revision control. Background processes are allowed as long as they do not cause a problem for other users. Crontab is also available.

sftp gives the error “Received message too long”

Question:

sftp gives the error “Received message too long”

Answer:

Check your .bashrc file. You likely have something in your .bashrc that is sending output and killing sftp. Most items that send output belong in .bash_profile.

The primary difference between .bashrc and .bash_profile is that .bashrc is used for non-interactive logins (sftp, etc.) and .bash_profile is used for interactive logins.

Keep your .bashrc free of anything that would send output.

Weird error message: “Suddenly the Dungeon collapses!! – You die”

Question:

I was ssh’d into the server when I saw the message:

Suddenly the Dungeon collapses!! – You die…

What happened? Did someone hack my account?

Answer:

No. This is the message that the screen program gives if you kill your own instance of screen (or if it otherwise crashes).

All is well and the server is fine.

ssh – server refused our public key

Question:

I can login to ssh correctly if I use my password. However attempts to use my key result in:

server refused our public key

Answer:

Make sure you do not have group or other write permissions on your .ssh directory

If in question, issue the command:


chmod 700 ~/.ssh
chmod 600 .ssh/authorized_keys*

sshd is very strict on the permissions for your keys. It will not use them if it believes the permissions are unsafe.