function sftp (id, inst) {
  if (inst) {
    globalState.setSession(id, inst)
    return inst
  }
  return globalState.getSession(id)
}
common functions for remote process handling,
for sftp, terminal and transfer