Sets the number of columns and rows for the terminal window size.
public setWindowSize ( integer $columns = 80, integer $rows = 24 ) | ||
$columns | integer | |
$rows | integer |
/** * Establish a SSH connection to the switch if necessary * * @throws ConnectionException If the connection fails */ protected function connect() { if (false == $this->ssh instanceof SSH2) { $this->ssh = new SSH2($this->ip); $this->ssh->setWindowSize($this->terminalColumn, $this->terminalLine); if (false == @$this->ssh->login($this->user, $this->password)) { throw new ConnectionException(sprintf("Connection to %s with user %s failed", $this->ip, $this->user)); } $this->ssh->read('continue'); $this->ssh->write($this->enterKey); $this->ssh->read('`' . $this->promptPattern . '`', SSH2::READ_REGEX); } }
/** * SSH connect via user&passwd or user&rsakey * * @param string $addr * @param string $port * @param bool $type - connect via user&rsakey(true), user&password(false) * @return mixed object | false */ protected function sshConnect($addr, $port, $type) { set_error_handler(array($this, "myErrorHandler"), E_ALL); $ssh = new SSH2($addr, $port); // user&password $ssh->setWindowSize(1024, 768); if (!$type && $ssh->login($this->config['routerboard']['rblogin'], $this->config['routerboard']['rbpasswd'])) { return $ssh; } // user&rsakey if ($type) { $key = new RSA(); $key->loadKey(file_get_contents($this->config['system']['ssh-dir'] . DIRECTORY_SEPARATOR . 'id_rsa')); if ($ssh->login($this->config['routerboard']['backupuser'], $key)) { return $ssh; } } return false; }