For openHAB 2 you can use the My.openHAB section of the migration tutorial here:
As discussed above, this cannot be done through My.openHAB. You either need to open a port in your router to allow access to your sshd running on the server or set up OpenVPN. I’ve a link to the tutorial I followed at the time above for OpenVPN.