The 21-year-old has won two caps, although he has dual nationality with the Republic of Ireland.
O'Shaughnessy spent the last two seasons with Championship club, having joined them from French club Metz.
He did not make a first-team appearance for the Bees, and spent time on loan with National League club Braintree and in Denmark with Midtylland.
Find all the latest football transfers on our dedicated page.
Cheltenham Town have signed Finland international centre-back Daniel O'Shaughnessy after a two-week trial.