It would probably be ok, as long as the two batteries are absolutely identical. If they aren't you could be overcharging one and undercharging the other.
The other proviso is to make sure the batteries are in the same state of charge when you connect them, preferably discharged. If you connect a charged battery to a discharged one you will get a very large current flowing which in the worst case scenario could cause a fire.