Raspberry pi has been having some erratic ssh and vnc performance, it just closes itself and do not let me reconnect, I need to restart it in order to do so. I tried connecting from my external ip, as if I were away from home and it is working much better than if I ssh directly to it's ip. Any suggestions?
A few things you can check:
You don't say what OS you are connecting from, but I have successfully SSH'ed from Mac OSX and Windows and even my iOS iPad. Mac OSX was the easiest, since I just used the Terminal app. I'd imagine any Linux would be as easy as the Mac. Reason the Mac was so easy is I didn't have any firewall on my Mac.
On Windows (7 and 2008 Server) I was initially caught out by firewall rules. So make sure your firewall allows Port 22 TCP access. Windows Firewall doesn't allow that by default and it's not so straightforward to enable it - but Google and you should be able to find out how to do it. This is most likely to be your root cause.
Next possibility is that you can't find your RPi from your other machine. Are you referring to it by its IP address? That should work (though I don't know if IPv6 will work, I've not used that). If your RPi has a DNS Name ago you're trying to connect to it by name, does the name actually resolve? Open up a CMD or Terminal window and type ping (where you'd replace the bit in brackets with your DNS name - like ping raspberry). If ping says it can't find your RPi then you need to figure out how to get a DNS name for your RPi - which is a whole new set of issues. In that case you're probably best going back to using IP address.
Last one I can think is that you have set up PuTTY to automatically log in but you haven't got the keys necessary for auto-login. I have set auto-login on my machines and it's not easy, but again there's quite a lot of info on Google.
The fact you can connect from an external machine indicates the obvious one isn't the case (that you have not got a running SSH daemon on your RPi!)
I copy the same answer I gave to Why does my Pi become unreachable from other computers but is still connected to the internet? because you probably have the same problem:
It seems that some versions of the Raspberry Pi tend to hang on high network load.
I solved the problems I had with mine by updating the firmware and allocating more memory for the USB driver.
To update the firmware, use rpi-update:
sudo apt-get install rpi-update sudo rpi-update
And to change the memory assigned to the USB driver, you should find this value in
vm.min_free_kbytes = 8192
And change it to