Publishing deals can last for a very long time. Historically they ran for 20-30 years but this is less common now.
You may be able to find a small publishing company that might be willing to give you a 2 year deal but you won't get a good rate and definitely won't get an advance (an up front payment against future earnings).
You only really get to sell your publishing rights once. The second time you sell publishing rights to a publisher it can get very complicated. I would say to hold on until you absolutely have to sell them. If you make it really big then you can sell them for a very large sum later on.
Look at the Darkness as an example. Their manager Sue Whitehouse decided that they guys shouldn't sell their publishing rights when they started getting some airplay and some small offers. She waited and waited, signed a record deal and let the ticket sales pay the bills. Then the band exploded, they were on every radio station and had a multi-platinum selling album. She then had to fight off bids for the publishing rights. In the end she sold their publishing rights for £1,000,000 + future royalties and Sue won manager of the year from the MMF.
Try not to sell your publishing rights until you abolutely have to.