In Sherlock, Magnussen whispers to Sherlock Redbeard. So how could he know about Redbeard? Sherlock couldn't tell him because he isn't so stupid. Mycroft won't obviously tell him. So how did Magnussen know about a story so old and so small about 'Redbeard'?
There is no logical explanation that we are aware of. It's likely just a plot seed inserted by the creators of the series (out of universe).
Sherlock himself isn't really aware, at this point, of the significance of Redbeard (he still thinks it's a dog).
It seems unlikely that Magnussen is aware of Eurus at this point either as her name does not appear under the list of pressure points applicable to Sherlock.
What DOES appear is the name Jim Moriarty who we know HAS been in contact with Eurus so it's conceivable that Magnussen somehow obtained information (but not all) from him.
IRENE ADLER (SEE FILE)
JIM MORIARTY (SEE FILE)
REDBEARD (SEE FILE)
HOUNDS OF THE BASKERVILLE