ps1 and ssh refactor