Add restricted SSH admin shell
This commit is contained in:
parent
64e0168dbf
commit
59ccf6c748
9 changed files with 358 additions and 14 deletions
|
|
@ -500,6 +500,12 @@ pub enum SshCommand {
|
|||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
AdminShell {
|
||||
node: String,
|
||||
command: String,
|
||||
#[arg(long)]
|
||||
bearer_secret: Option<String>,
|
||||
},
|
||||
Cert {
|
||||
#[command(subcommand)]
|
||||
command: SshCertCommand,
|
||||
|
|
@ -1050,6 +1056,15 @@ fn request_for_command(command: Command) -> Result<ControlRequest> {
|
|||
node,
|
||||
bearer_secret,
|
||||
},
|
||||
SshCommand::AdminShell {
|
||||
node,
|
||||
command,
|
||||
bearer_secret,
|
||||
} => ControlRequest::SshAdminShell {
|
||||
node,
|
||||
command,
|
||||
bearer_secret,
|
||||
},
|
||||
SshCommand::Cert { command } => match command {
|
||||
SshCertCommand::Request {
|
||||
public_key,
|
||||
|
|
@ -2209,6 +2224,29 @@ fn print_response(response: ControlResponse, json: bool) -> Result<()> {
|
|||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::SshAdminShellOutput {
|
||||
peer_node_id,
|
||||
peer_agent_id,
|
||||
endpoint_id,
|
||||
command,
|
||||
output,
|
||||
allowed,
|
||||
reason,
|
||||
note,
|
||||
} => {
|
||||
if allowed {
|
||||
println!("{output}");
|
||||
} else {
|
||||
println!("ssh admin shell denied by {peer_node_id}");
|
||||
}
|
||||
println!("command: {command}");
|
||||
println!("peer: {peer_node_id}");
|
||||
println!("agent: {peer_agent_id}");
|
||||
println!("endpoint: {endpoint_id}");
|
||||
println!("allowed: {allowed}");
|
||||
println!("reason: {reason}");
|
||||
println!("note: {note}");
|
||||
}
|
||||
ControlResponse::NotImplemented { module, command } => {
|
||||
println!("{module} {command}: not implemented yet");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue