Q:

GCE ssh internal ip Connection closed by foreign host

I have 2 instances in the same project, and inside one instance(a) 
i want to connect to another instance(b) via ssh using the internal ip 
but the telnet  22 give me "Connection closed by foreign host".
I want to connect via ssh because in a php project, i want to execute ssh2_exec to remote launch a php file.
The firewall configuration is:

There is a way to solve this, thnks.

A:

Not firewall: you are able to "connect" to the other server, but it doesn't like you. If you were firewalled out, you wouldn't connect at all.
Options could be (among many others)

you are trying to SSH as "root" but root is not permitted to SSH in.
you are trying to connect as another user that does not have permission.
the user you are trying to connect at has no shell (or is set to '/bin/nologin')
the password you are providing is incorrect
the certificate(s) you are providing are not correct
the server is set to only allow certain IPs (check /etc/hosts.allow and /etc/hosts.deny)
the server does not allow connection through telnet (telnet passes username password unsecured so may be blocked, use SSH instead. Is telnet.d running/configured?)

Check logs on destination server for more clues.

Suggested solution:

connect to the first server using SSH, then run "ssh user:pass@server" to test the connection from one server to the next. If that fails, get that working first.
to do it programatically in php, try with phpseclib (http://phpseclib.sourceforge.net/) - it's a very old library but easy to debug. 

