David Cameron's links with the media were too close, former cabinet secretary Lord O'Donnell has said.
The peer - who retired from the post at the end of last year - said he had tried to ensure ministers worked through the civil service and maintained a distance from the press.
Cameron admitted last July that he and other politicians had allowed themselves to get "too close" to media proprietors and editors, and he has since said that relations were "too cosy".
"I think the Prime Minister himself, the current Prime Minister, has said that he felt his relationships had got too close, and I agree with that."
Lord O'Donnell told the inquiry into press standards that politicians from opposition parties should have a different relationship with journalists than Government ministers.
He said: "You have much fewer resources, so you do not have big press offices and the like, so you do tend to make closer personal relationships with journalists.
"There tends to have been swapping of mobile phone numbers, all of those sorts of things."
Lord O'Donnell said MPs should be "much more careful" once their party forms a government.
The peer added that the inquiry had an opportunity to issue guidelines specifically for opposition parties on their relationships with the press.
"I think you would want to put it to the leaders of all the parties, 'Here is a set of rules that we think opposition parties should abide by', he said.
Lord O'Donnell also said Andy Coulson was wrong not to declare that he held shares in News Corporation when he accepted a job working for David Cameron in Downing Street.
The former cabinet secretary said: "A form was signed but it didn't disclose the share holding and it should have done".
In his evidence to the inquiry into the relationship between politicians and the press, Coulson admitted he held £40,000 worth of shares in News Corp. while serving as Downing Street director of communications but said he did not think it represented a conflict of interest.
"Whilst I didn’t consider my holding of this stock to represent any kind of conflict of interest, in retrospect I wish ] had paid more attention to it," he said.
"I was never asked about any share or stock holdings and because I knew that l wasn’t involved in any commercial issues, including the BSkyB bid, it never occurred to me that there could be a conflict of interest
"Since resigning from my role as Downing Street communications director l have given thought to one issue which I now accept could have raised the potential for conflict."
The former editor of the News of the World editor resigned from his No.10 job in January 2011 after coming under sustained pressure over incidents of phone hacking at the tabloid.
During his time in government ministers were tasked with adjudicating as to whether News Corporation should be allowed to take over the BSkyB broadcaster.
Following his evidence Downing Street admitted that Coulson broke the civil service code by failing to declare the shares.
LAST WEEK AT LEVESON:
Suggested For You
SUBSCRIBE AND FOLLOW
Get top stories and blog posts emailed to me each day. Newsletters may offer personalized content or advertisements.Learn more