ssh_file_replace_line
Replace a specific line in a remote file with a new line using exact content matching, supporting sudo for privileged files.
Instructions
Replace a unique line in a file with a new line.
PARAMETERS:
file_path: Path to the file to modify
match_line: Exact line content to match and replace (whitespace-trimmed)
new_line: New line to insert in place of the match
use_sudo: Use sudo for the operation (default: false)
force: Force operation even if file can't be read (sudo only) (default: false)
RETURNS: A dictionary with operation status including:
success: Boolean indicating if operation succeeded
file_path: Path to the modified file
EXAMPLES: Example 1: Replace a commented line with an active configuration
{
"file_path": "/etc/ssh/sshd_config",
"match_line": "#ClientAliveInterval 0",
"new_line": "ClientAliveInterval 300"
}Note: To delete a line entirely, use the dedicated ssh_file_delete_line_by_content tool instead.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | Path to the file to modify | |
| match_line | Yes | Exact line content to match and replace | |
| new_line | Yes | New line to insert in place of the match | |
| use_sudo | No | Use sudo for the operation | |
| force | No | Force operation even if file can't be read (sudo only) |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||