What you're referring to is the technique for playing barre chords. It is often one of the hardest techniques for anyone who is relatively new to playing guitar, but don't give up, as it doesn't necessarily take long to improve on. The problem is just that it's hard to mask and you end up getting frustrated as the sound it can produce when learning isn't particularly pleasing.
One important part of the technique is to make sure you're using the bony part of your finger rather than the fleshy part. This should produce a more consistent sound and will make it easier as you practice more.
In my personal experience however, the setup of your guitar can be the single biggest obstacle to learning the technique. If your guitar's action is too high you will find that you're having to put a lot of effort into getting the strings to press against the fret. You will know if your guitar's action is too high if the strings are not a consistent height above the fret board, particularly as you go further down. On cheaper guitars that haven't had any professional set up done on them, the action will often be far too high, and acoustic guitars are often the worst for this. Whist you can adjust your action relatively easily (electric guitars in particular), any guitar store will do this for you typically at a low cost. There are also some other adjustments that a technician might make (such as adjusting the truss rod), so it is often better to get a professional to do a full setup for your guitar. Also discuss with them whether you may benefit from a lighter gauge of strings. All of these things combined can make the learning experience far less painful.