1. Remembering Allah (SWT) always makes the real believer remember the Imam of the time because of the fact that Imam of the time is the Deputy of the Prophet (SAWA) who is the Deputy of Allah (SAWA). More and more sincere remembrance of Allah makes the believer more near to the Imam of the time, Al-Mahdi (AS).
2. Remembering the Imam means feeling his presence with us in this world and how he feels happy when we do good and unhappy if we do bad, God forbid. When we really feel that he is with us in this world and he is informed and he responds to our deeds, we will always try to obey Allah which means obey the Imam (AS), and avoid any act which can displease him. When people are asleep, those believers who know that Imam Al-Mahdi (AS) will be happy when they pray the Night Prayer, will get up and perform the Night Prayer which is just one example of feeling the presence of the Imam (AS) and making him happy by worshipping Allah (SWT).
3. Continuous praying for the Imam in every Prayer and supplication because no one among human beings on this world is more dear to us that him, and praying for his re appearance means praying for the solution of all the problems.
4. Paying Sadaqa and giving in charity on behalf of Imam Al-Mahdi (AS) makes us more near to him, especially when we do it secretly just for the sake of Allah (SWT) and not for any worldly aim.
5. Reciting Du'a Al-'Ahd and Ziyarat Aal Yaseen. Some very pious persins who met the Imam (AS) narrated that he encouraged them to perform Night Prayer every night and recite Ziyarat Aashura and Ziyarat Al-Jami'ah every day.
6. Serving the religion of the Imam (AS) which is the Real Islam of the Prophet Muhammad (SAWA) and spreading it among people and defending it from the doubts of the enemies makes you a servant of Imam Al-Mahdi (AS).
7. Serving people including the followers of Imam (AS) especially those who are in need, makes the Imam (AS) happy with you. Helping the believers and making them happy, makes Allah (SWT), the Prophet (SAWA) and all Ahlul Bayt (AS) happy with you.
These are just few examples of the ways to gain more nearness from the Imam of the Time (AS).