SSH Read from socket failed: Connection reset by peer

After installing a container with lxc I wasn’t able to connect via ssh to my container, I get the following message :

root@ns313:~# ssh 10.50.10.10
Read from socket failed: Connection reset by peer

Network works normally, I can ping, hotst both direction and I can get pages from apache’s container from the dom0.

I tried to connect to ssh from container, in local and I get the same error.

root@container:/etc/ssh#ssh 10.50.10.10 -l root
Read from socket failed: Connection reset by peer

Strange, first time ssh doesn’t work on any machine.
Try restart sshd

root@container:/etc/ssh# /etc/init.d/ssh restart
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
[....] Restarting OpenBSD Secure Shell server: sshdCould not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_dsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
. ok 

SSH keys are missing, to fix it, run this command :

root@container:/etc/ssh# ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N ''

SSH How to connect without password

A classic hack for linux users, connect via ssh without password.

First, on your client, generate public key

ssh-key-gen -t rsa

keep ~/.ssh/id_rsa by default.

Copy public key (~/.ssh/id_rsa.pub) from your client to the file ~/.ssh/authorized_keys2 on the server with the ssh-copy-id binary.

Then edit your ~/.ssh/config file on client side to custom your params:

Host dev
  HostName dev.domain.com
  Port 22
  User root

Finaly, you can add an alias in your ~/.bashrc

alias dev='ssh dev'

Now, to launche a ssh connection, just run

dev

Robots.txt disallow all

To prevent google to reference your dev website, you can add a robots.txt file to your web root directory and fill it with

User-agent: *
Disallow: /

The “User-agent: *” means that the file applies to all robots. The “Disallow: /” means the robot will not visit any pages on the website.

ERROR: This RRD was created on another architecture

You are migrating cacti from a 32bits machine to a 64bits machine and you get this error message : “ERROR: This RRD was created on another architecture” ?

To fix it, you need to convert on your 32bits machine the .rrd file to xml files.

    for i in `ls *.rrd`; do rrdtool dump $i > $i.xml; done

And on your 64bits machine, transform your XML files to rrd files :

for i in `ls *.xml`; do rrdtool restore $i `echo $i |sed s/.xml//g`; done

IE blocking cookies in frames

For “security” reasons (stuff related to P3P Platform for Privacy Preferences), Internet Explorer does not accept cookies for a site inside a frame. But you can force him to accept cookies by adding this in your http header

PHP:

header('P3P:CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');

ASP.NET:

HttpContext.Current.Response.AddHeader("p3p","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"");

Django:

response = render_to_response('mytemplate.html')
response["P3P"] = 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"'

JSP:

response.addHeader("P3P","CP=\"IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT\"")