Students could be told not to return home at Christmas if the spread of the coronavirus has not been controlled, the deputy first minister has said.
John Swinney said it was a situation the government wanted to avoid but it was a "realistic possibility".
He told BBC Scotland the government would have to look at "other scenarios and other plans" if the virus was still spreading rapidly.
The National Union of Students (NUS) said a clear plan was needed urgently.
A phased end to the university term is being considered.
Speaking on BBC Radio's Good Morning Scotland, Mr Swinney said students may also need to make a staggered return in January with more online learning for a longer period in the new year.
"We want students to be able to return home, but I have to be realistic with you, that if we have a situation where the virus has not been controlled, then we will have to look at other scenarios and other plans," he said.
"There obviously is... a risk that if the virus is not contained then we may not be able to support the return of students to their homes. We want to avoid that - but it is a realistic possibility."
Mr Swinney said the Scottish government was working with the universities, other governments across the UK and with the National Union of Students to ensure the safe return of students at Christmas.
'People will go home anyway'
Nell Manson from Lancaster was one of the thousands of students who had to self-isolate during the September outbreak at Glasgow University.
She told the BBC she does not believe many students will stay over Christmas if asked to by the Scottish government.
She said: "I am really hoping we can go home but it is understandable if we can't. I feel like a lot of people will go home anyway, especially as we have not seen our families for so long already out of worry surrounding moving around the country."
Reese Chamberlain from New York is facing a halls of residence Christmas, even if the Scottish government say he can leave.
He said: "The holiday period is too short for me to isolate for two weeks on both ends of my trip. I do know a lot of students are tired of being told 'wait and see' and they still don't know what the curriculum will look like in Semester 2, if it will be online or hybrid.
"I wouldn't be surprised if students go home for Christmas and stay home because the teaching afterwards will be mostly online."
There was a spike in Covid-19 infections in Scotland at the start of term in September, with more than 1,000 students having to self-isolate within their halls of residence.
At the time, ministers said they did not want to see a "mass exodus" from campuses, but advised that students who were struggling in university accommodation could return home.
The deputy first minister told BBC Scotland there was an "expectation" that students would be reunited with their families at Christmas, but said it was important to recognise that the movement of a large number of people risked transmitting the virus to other parts of the country.
"If we engage effectively in the measures and the restrictions that the government is putting in place just now, then we increase the chances of being able to share more time with family around about Christmas time, but that very much depends... on the success that we have in reducing the prevalence of the virus," he said.
Mr Swinney said the return of students in January could also be dependent on their personal circumstances.
"They could be going back to family homes where there could be significant vulnerability and that would raise major issues about whether it was advisable and wise for students to be essentially switching households at the turn of the year," he said.
At her daily coronavirus briefing, First Minister Nicola Sturgeon added that her government would "do everything we can" to get students home for Christmas, but said there was "inherent uncertainty in the situation".
She said: "The really difficult thing in all of this is that we are living through an inherently uncertain and unpredictable pandemic, so we can't give cast iron certainty on anything right now that people desperately want, and that I want desperately to be able to give.
"We have to steer the country through this and find the safest possible path with as much normality attached to it as we can."
The NUS said a clear and coherent plan was required urgently.
President Matt Crilly said: "This uncertainty does nothing for students' mental health and wellbeing. It goes without saying that for many students this first semester isn't what they signed up for. In terms of a return to campus in the new year, we must avoid a repeat of the mass outbreaks we saw among the student population in the autumn."
He also said universities and colleges needed to clearly communicate with their students on what their next semester is going to look like, so that students can make an informed decision on whether they wanted to return.
NUS Scotland believes remote learning should be the default position.
Mr Crilly said: "That way no student has to go back to campus unless absolutely necessary. No student should be left asking themselves, again, why they've been asked to return for no good reason."
The deputy first minister also warned against children guising "door-to-door" this weekend to collect sweets at Halloween.
Mr Swinney said he appreciated it was "disappointing advice", but told the BBC the "interaction of humans" was how the virus was spreading.
"[The virus] can also be spread by the touching items like bags of sweeties, so quite conceivably, without anybody knowing that they were doing any harm to anybody else, somebody could give a child, an assembled bag of sweeties," he said.
"Those bags could be the purveyors of coronavirus."