ssh: complexity refactors