getSshPublicKey
Retrieve the SSH public key for the current user to configure secure remote access and authentication.
Instructions
获取当前用户的 SSH 公钥
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "getSshPublicKey"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:696-713 (handler)Handler implementation for the getSshPublicKey tool. It lists all .pub files in the user's ~/.ssh directory, reads their contents, and returns the public keys as a JSON array.
case "getSshPublicKey": { const sshKeys: string[] = []; const sshDir = `${os.homedir()}/.ssh`; const keyFiles = fs.readdirSync(sshDir).filter(file => file.endsWith('.pub')); for (const keyFile of keyFiles) { const filePath = `${sshDir}/${keyFile}`; const publicKey = fs.readFileSync(filePath, 'utf8'); sshKeys.push(publicKey); } return { content: [{ type: "text", text: JSON.stringify(sshKeys, null, 2) }] }; } - src/index.ts:253-261 (registration)Registration of the getSshPublicKey tool in the list of available tools, including its name, description, and empty input schema.
{ name: "getSshPublicKey", description: "获取当前用户的 SSH 公钥", inputSchema: { type: "object", properties: {}, required: [] } }, - src/index.ts:256-260 (schema)Input schema for the getSshPublicKey tool, which expects no parameters (empty object).
inputSchema: { type: "object", properties: {}, required: [] }