It's definitely a process. I can tell you that much. I am still working on learning to trust people myself. First and foremost, I think it's important that you try and figure out what has caused you to have such issues? Abuse? Mistreatment? Social rejection? Secondly, I suggest trying to see a professional, as things like this you have to work through and therapy is a good way to do so. A professional can offer a fresh perspective to a situation, which might be needed.
The best advice I can give you is persistence. Practice catching yourself when you're shutting people out and try to consistently combat it when you see it. Be aware of yourself. Be gentle with yourself, too as mistakes will be made, because no one is perfect. Eventually, if you work at it, it will get better, slowly but surely. The thing is, you have to give all of yourself to it and often times, fight yourself when your brain is screaming at you to do the exact opposite.
Nothing grows in a comfort zone.