getSshPublicKey
Retrieve your SSH public key directly from the current operating environment for secure access and authentication purposes.
Instructions
获取当前用户的 SSH 公钥
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Input Schema (JSON Schema)
{
"properties": {},
"required": [],
"type": "object"
}
Implementation Reference
- src/index.ts:696-713 (handler)Handler implementation for the getSshPublicKey tool. It reads all public key files (*.pub) from the user's ~/.ssh directory and returns their contents 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 listTools handler response. Includes name, description, and input schema (empty object).{ name: "getSshPublicKey", description: "获取当前用户的 SSH 公钥", inputSchema: { type: "object", properties: {}, required: [] } },
- src/index.ts:256-260 (schema)Input schema definition for the getSshPublicKey tool, which requires no parameters.inputSchema: { type: "object", properties: {}, required: [] }