SCOTLAND'S most senior civil servant has revealed how he used to "manage" former First Minister Alex Salmond through flattery.

Using Salmond as an example in a talk to public servants, Sir Peter Housden said a good way of "managing your boss" was to claim you needed their advice as "people like that".

He said: "Understand your boss's strengths and weaknesses and play to them".

Housden, who retires next month after five years as the Scottish Government's Permanent Secretary, also called former UK Cabinet Secretary Sir Gus O'Donnell a "hugely talented, hugely disorganised man" who couldn't be relied on "to tie his shoelaces".

The unusually frank remarks were made at a day-long government event in Edinburgh last month called "Leading Integration to Deliver Better Outcomes", which was aimed at people involved in the forthcoming integration of health and social care services.

Housden's demob happy contribution was a half-hour session called "My Journey as a Leader: Reflections and Learning", which has now been posted online.

He began by recalling the "bitter experience" of becoming permanent secretary in the Office of the Deputy Prime Minister in 2005 under Labour's John Prescott.

He said "a mixture of arrogance and naivete" led him to underestimate the problems in the department and he had "several years of not really having any job description".

He admitted: "I just didn't do the necessary preparation. I didn't do the due diligence about what I was going into it. I think I sort of assumed my charisma and charm would be sufficient, and when got there it was pretty close to a nightmare."

Housden said he was far better prepared when he moved to Scotland in 2010.

Asked about managing "upward relationships" - civil service jargon for handling bosses - Housden told his audience: "I think the key thing is about managing them. The worst thing you can do is allow your manager to manage you."

Urging people to focus on getting what they wanted from politicians, Housden went on: "Let's talk about Alex Salmond because he's no longer the First Minister.

"When I used to go and see him, I'd first of all be quite contained about the number of things I wanted to talk to him about.

"I didn't go and say, 'There's 45 things I want to tell you today, First Minister'. Three was the favourite number. And often I would say to him, 'There are three things on which I want to take your advice.'

"Now people like that. People like to have their advice sought.

"And then, this is the key bit, I used to look at his face and see which of these, if any, he wanted to talk about."

Scottish LibDem leader Willie Rennie said: "After all this time we now discover that Alex Salmond was not First Minister but just a puppet on a string."

Housden has had a controversial career as Permanent Secretary.

He quickly became a figure of fun after the leak of his weekly memos to staff, which included banal observations on golf, shopping, pop music and housekeeping.

"We had to pay £28 for a snow shovel," he once moaned to staff on a pay freeze.

Housden was later accused of being too close to Salmond.

Last month a Commons committee said Housden should have blocked the use of public money for the SNP's White Paper on Independence before the referendum, as it was a "partisan" manifesto that did not meet "factual standards".

A government spokeswoman said: "This event focused on leadership and Sir Peter offered an insight into his excellent working relationship with the then First Minister."