When you think back to the best bosses you have had and the strongest leaders you have experienced, what things stand out about them that are different? I am going to assume that most if not all of them did a great job of acknowledging their employees, saying thank you, supporting and building up others, and avoiding assumptions and judgments.
Sure, it is a basic human need to be valued and feel that we are contributing. It is also a real part of our psyche and ego. Despite the need for acknowledgment, great leaders gain the most credibility by deflecting credit to their teams.
As per the above, if asked who the worst boss you ever had was, it is likely that it was someone who did not give credit and belittled their direct reports.
Think about this. To do so, you must first step back and check your ego. Giving credit to others for your success will actually benefit you more than being recognized by your boss. A novel concept and not without some risk. I would just argue that the upside likely far outweighs the risk and recognizing others will propel your career much further and faster than seeking credit.
I am sure that I presented this in a manner that implies that it is easy to do. It is not and is in fact hard to do. Like any habit, this requires repetition and a conscious approach. Exercises might include the daily preparation of thank you cards that you send out or a goal of complimenting X number of people for something that they did well. This activity cements the habit and allows you to become a person who deflects credit and recognizes others.
I have long been a believer in Karma. Good or bad, we reap what we sow. If we help others to succeed, grow and get what they want, all our goals and dreams will be achieved as well. This should not be why we do it, but the upside benefits will far outweigh the risk of not getting noticed, being passed up for a promotion, etc.