Ensure --cookie is set before remsh starts, closes #1190