It depends.
The question says to ignore whether classified material is present, but that fact is quite relevant, as is whether the person in question has or has held a security clearance and a need to know.
In the general case, no, there is no such requirement.
For special cases (like the one in this incident) where classified information is involved, it's more complicated.
If you are a government employee, officer, or contractor with a security clearance, then knowingly retaining classified information in an unauthorized location is a crime under 18 USC 1924.
(a) Whoever, being an officer, employee, contractor, or consultant of the United States, and, by virtue of his office, employment, position, or contract, becomes possessed of documents or materials containing classified information of the United States, knowingly removes such documents or materials without authority and with the intent to retain such documents or materials at an unauthorized location shall be fined under this title or imprisoned for not more than five years, or both.
(b) For purposes of this section, the provision of documents and materials to the Congress shall not constitute an offense under subsection (a).
(c) In this section, the term “classified information of the United States” means information originated, owned, or possessed by the United States Government concerning the national defense or foreign relations of the United States that has been determined pursuant to law or Executive order to require protection against unauthorized disclosure in the interests of national security.
Of course, providing the classified information to another unauthorized person would also be illegal under 18 USC 798, but merely retaining it without authorization or retaining it in an unauthorized place is sufficient for prosecution under 18 USC 1924.
Whether it's illegal for someone who is not a cleared government employee, contractor, etc. who has sworn to protect classified information to knowingly publish classified information that they've gained access to is something of an open question. The most relevant case I'm aware of is the landmark New York Times Co. v. United States, 1971, where the Supreme Court overturned an injunction that the Nixon administration had obtained against the New York Times for further publication of contents of the Pentagon Papers. The Supreme Court ruled that barring the New York Times from continuing to publish contents of the papers would violate the First Amendment, despite their status as classified material. However, the court stopped short of ruling that such an injunction would always be illegal or that the publication could not be prosecuted later.
The lack of a clear ruling on whether the government may prosecute a non-cleared person for disclosure of classified information is due primarily to the lack of attempted prosecutions for such cases. The MTSU First Amendment Center quotes the litigation director of the Reporters Committee for Freedom of the Press as describing a WWII-era case against a reporter from the Chicago Sunday Tribune as stating that the case was "the only time in American history that the United States government has ... taken steps toward prosecuting a member of the media under the Espionage Act." The government convened a grand jury in the case, but ultimately declined to charge him and instead seal the case, so no rulings on the legality of such charges arose from the case.
In the case of Julian Assange, who was obviously not a cleared person, his charges (and subsequent guilty plea) stemmed not from merely disclosing information that had been given to him, but rather from conspiracy to obtain the documents illegally in the first place. Conspiring with someone to steal classified information from the government is obviously illegal, but that is not relevant to the case in the question.