Path: blob/master/src/applications/drydock/interface/command/DrydockSSHCommandInterface.php
12262 views
<?php12final class DrydockSSHCommandInterface extends DrydockCommandInterface {34private $credential;5private $connectTimeout;67private function loadCredential() {8if ($this->credential === null) {9$credential_phid = $this->getConfig('credentialPHID');1011$this->credential = PassphraseSSHKey::loadFromPHID(12$credential_phid,13PhabricatorUser::getOmnipotentUser());14}1516return $this->credential;17}1819public function setConnectTimeout($timeout) {20$this->connectTimeout = $timeout;21return $this;22}2324public function getExecFuture($command) {25$credential = $this->loadCredential();2627$argv = func_get_args();28$argv = $this->applyWorkingDirectoryToArgv($argv);29$full_command = call_user_func_array('csprintf', $argv);3031$flags = array();3233// See T13121. Attempt to suppress the "Permanently added X to list of34// known hosts" message without suppressing anything important.35$flags[] = '-o';36$flags[] = 'LogLevel=ERROR';3738$flags[] = '-o';39$flags[] = 'StrictHostKeyChecking=no';4041$flags[] = '-o';42$flags[] = 'UserKnownHostsFile=/dev/null';4344$flags[] = '-o';45$flags[] = 'BatchMode=yes';4647if ($this->connectTimeout) {48$flags[] = '-o';49$flags[] = 'ConnectTimeout='.$this->connectTimeout;50}5152return new ExecFuture(53'ssh %Ls -l %P -p %s -i %P %s -- %s',54$flags,55$credential->getUsernameEnvelope(),56$this->getConfig('port'),57$credential->getKeyfileEnvelope(),58$this->getConfig('host'),59$full_command);60}61}626364