Skip to content

Commit 26582eb

Browse files
author
epriestley
committedDec 30, 2013
Provide a more helpful message if a user connects via raw SSH
Summary: We currently print a fairly vague, technical message which is ambiguous about indicating success or an error if you aren't familiar with SSH. Test Plan: $ ssh -T dweller@localhost phabricator-ssh-exec: Welcome to Phabricator. You are logged in as epriestley. You haven't specified a command to run. This means you're requesting an interactive shell, but Phabricator does not provide an interactive shell over SSH. Usually, you should run a command like `git clone` or `hg push` rather than connecting directly with SSH. Supported commands are: conduit, git-receive-pack, git-upload-pack, hg, svnserve. Reviewers: btrahan, dctrwatson Reviewed By: dctrwatson CC: aran Differential Revision: https://secure.phabricator.com/D7854
1 parent 591df78 commit 26582eb

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed
 

‎scripts/ssh/ssh-exec.php

+18-10
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,28 @@
5858
$original_command = getenv('SSH_ORIGINAL_COMMAND');
5959
}
6060

61+
$workflows = id(new PhutilSymbolLoader())
62+
->setAncestorClass('PhabricatorSSHWorkflow')
63+
->loadObjects();
64+
65+
$workflow_names = mpull($workflows, 'getName', 'getName');
66+
6167
// Now, rebuild the original command.
6268
$original_argv = id(new PhutilShellLexer())
6369
->splitArguments($original_command);
6470
if (!$original_argv) {
65-
throw new Exception("No interactive logins.");
71+
throw new Exception(
72+
pht(
73+
"Welcome to Phabricator.\n\n".
74+
"You are logged in as %s.\n\n".
75+
"You haven't specified a command to run. This means you're requesting ".
76+
"an interactive shell, but Phabricator does not provide an ".
77+
"interactive shell over SSH.\n\n".
78+
"Usually, you should run a command like `git clone` or `hg push` ".
79+
"rather than connecting directly with SSH.\n\n".
80+
"Supported commands are: %s.",
81+
$user->getUsername(),
82+
implode(', ', $workflow_names)));
6683
}
6784

6885
$ssh_log->setData(
@@ -78,15 +95,6 @@
7895

7996
$original_args = new PhutilArgumentParser($original_argv);
8097

81-
$workflows = array(
82-
new ConduitSSHWorkflow(),
83-
new DiffusionSSHSubversionServeWorkflow(),
84-
new DiffusionSSHMercurialServeWorkflow(),
85-
new DiffusionSSHGitUploadPackWorkflow(),
86-
new DiffusionSSHGitReceivePackWorkflow(),
87-
);
88-
89-
$workflow_names = mpull($workflows, 'getName', 'getName');
9098
if (empty($workflow_names[$command])) {
9199
throw new Exception("Invalid command.");
92100
}

0 commit comments

Comments
 (0)
Failed to load comments.