MCPcopy Create free account
hub / github.com/TeleBoxOrg/TeleBox_Plugins / changePassword

Method changePassword

ssh/ssh.ts:902–937  ·  view source on GitHub ↗
(msg: Api.Message, args: string[])

Source from the content-addressed store, hash-verified

900 try {
901 peer = await client.getEntity(targetChat);
902 } catch {
903 peer = "me";
904 }
905 }
906
907 // 发送导出文件
908 await client.sendFile(peer, {
909 file: new CustomFile(
910 "ssh_keys_export.zip",
911 fs.statSync(archivePath).size,
912 "",
913 fs.readFileSync(archivePath)
914 ),
915 caption: `📦 <b>SSH密钥导出包</b>\n\n🖥️ 服务器: ${hostname}\n📊 密钥数量: ${lines.length}\n📅 导出时间: ${dayjs().format("YYYY-MM-DD HH:mm:ss")}\n\n📁 <b>包含文件:</b>\n• authorized_keys_export.txt (带注释说明)\n• authorized_keys (纯密钥文件)\n\n⚠️ <b>安全提示:</b> 请妥善保管密钥文件`,
916 parseMode: "html"
917 });
918
919 await msg.edit({
920 text: `✅ <b>密钥导出成功</b>\n\n📊 导出密钥数量: ${lines.length}\n📁 文件已发送到: ${targetChat === "me" ? "收藏夹" : htmlEscape(targetChat)}\n\n💡 <b>文件说明:</b>\n• 带注释的完整导出文件\n• 纯净的authorized_keys文件\n• 可直接用于其他服务器配置`,
921 parseMode: "html"
922 });
923
924 // 清理临时文件
925 fs.rmSync(workDir, { recursive: true, force: true });
926
927 } catch (error: any) {
928 throw new Error(`导出授权密钥失败: ${error.message}`);
929 }
930 }
931
932 // 修改root密码
933 private async changePassword(msg: Api.Message, args: string[]): Promise<void> {
934 const newPassword = args.join(" ").trim();
935
936 if (!newPassword) {
937 await msg.edit({
938 text: `❌ <b>请提供新密码</b>\n\n示例: <code>${mainPrefix}ssh passwd 新密码123</code>`,
939 parseMode: "html"
940 });

Callers 1

handleSSHMethod · 0.95

Calls 3

validatePasswordFunction · 0.85
shellEscapeFunction · 0.85
editMethod · 0.45

Tested by

no test coverage detected