SDKs overview
Teleport offers Software Development Kits (SDKs) and client libraries to enable programmatic interaction with its infrastructure access platform. These tools allow developers to integrate Teleport's capabilities directly into their applications, automation scripts, and custom workflows. The primary use cases for Teleport's SDKs include automating user and role management, programmatically granting or revoking access to resources, and embedding secure session management within custom applications Teleport API documentation. By utilizing the SDKs, organizations can extend Teleport's unified access plane to cover bespoke systems or create custom front-ends for infrastructure access.
The official SDKs are designed to interact with the Teleport API, which provides a gRPC-based interface for managing Teleport clusters, users, roles, and resources. This allows for fine-grained control over access policies and auditing capabilities, ensuring that all programmatic interactions adhere to the same security standards as manual access through the Teleport client tools. The SDKs abstract away the complexities of direct gRPC communication, offering idiomatic interfaces for each supported language.
Integrating with Teleport's SDKs typically involves authenticating with a Teleport cluster, then using the SDK client to perform operations such as listing available servers, requesting access to a specific resource, or managing user identities. The architecture supports both short-lived programmatic access and long-running services that require continuous interaction with the Teleport control plane. This flexibility is crucial for scenarios ranging from CI/CD pipelines needing temporary access to deploying new infrastructure, to internal tools providing a custom developer portal for engineers Teleport Go client example.
Official SDKs by language
Teleport provides official SDKs for several popular programming languages, designed to offer stable and supported interfaces for interacting with the Teleport API. These SDKs are maintained by the Teleport development team and are recommended for production environments requiring reliable integration.
| Language | Package/Module | Installation Command | Maturity |
|---|---|---|---|
| Go | github.com/gravitational/teleport/api |
go get github.com/gravitational/teleport/api |
Stable |
| Python | teleport-client |
pip install teleport-client |
Stable |
| Node.js | @gravitational/teleport-api |
npm install @gravitational/teleport-api |
Stable |
Installation
Each official Teleport SDK can be installed using the standard package manager for its respective language environment. Prerequisites typically include having the language runtime and its package manager installed and configured on the development machine.
Go SDK
The Go SDK for Teleport provides direct access to the Teleport gRPC API. It is commonly used for building automation tools, custom services, and integrations that require low-level control over Teleport operations.
go get github.com/gravitational/teleport/api
After installation, you can import the necessary packages into your Go project to begin interacting with the Teleport API Go client reference.
Python SDK
The Python SDK offers an idiomatic Python interface to the Teleport API, simplifying tasks such as user management, session recording playback, and access requests. It is suitable for scripting, data analysis, and integrating Teleport with existing Python-based systems.
pip install teleport-client
Once installed, the teleport-client package can be imported into Python scripts to establish connections and perform operations Python client guide.
Node.js SDK
The Node.js SDK for Teleport allows JavaScript developers to interact with the Teleport API within Node.js applications. This is useful for building web-based administration panels, server-side applications that provision access, or integrating with other JavaScript-based tools.
npm install @gravitational/teleport-api
After installation, the @gravitational/teleport-api module can be imported to create clients and call API methods Node.js client documentation.
Quickstart example
This example demonstrates how to use the Teleport Go SDK to list active SSH sessions on a Teleport cluster. This requires an authenticated Teleport client with appropriate permissions.
package main
import (
"context"
"fmt"
"time"
"github.com/gravitational/teleport/api/client"
"github.com/gravitational/teleport/api/client/proto"
"github.com/gravitational/teleport/api/types"
log "github.com/sirupsen/logrus"
)
func main() {
// Replace with your Teleport proxy address and authentication details
teleportProxyAddr := "my.teleport.proxy:443"
teleportAuthToken := "your-teleport-auth-token" // Or use mTLS client certificates
log.SetLevel(log.DebugLevel)
// Create a new Teleport client configuration
cfg := client.Config{
Addrs: []string{teleportProxyAddr},
UseWebProxy: true,
Keys: []*client.Key{
// For demonstration, using an insecure client without validating server certs.
// In production, always use mTLS client certificates or secure token exchange.
// Example: client.LoadKeyFromFile("/path/to/teleport_key", client.WithPassword("password"))
&client.Key{},
},
ClientTimeout: 10 * time.Second,
}
// Create a new Teleport client
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
clt, err := client.New(ctx, cfg)
if err != nil {
log.Fatalf("Failed to create Teleport client: %v", err)
}
defer clt.Close()
// Authenticate (if not using mTLS client certificates directly)
// For token-based authentication, this step would involve a token exchange.
// In a real-world scenario, you might have pre-configured keys or use a login flow.
// List all active sessions
sessions, err := clt.GetSessions(ctx, &proto.GetSessionsRequest{}) // or clt.GetSSHConnections
if err != nil {
log.Fatalf("Failed to get active sessions: %v", err)
}
if len(sessions) == 0 {
fmt.Println("No active sessions found.")
return
}
fmt.Println("Active Teleport sessions:")
for _, session := range sessions {
sessionID := session.GetName()
user := session.GetLogin()
host := "N/A"
if len(session.GetParticipants()) > 0 {
host = session.GetParticipants()[0].GetRemoteAddr()
}
fmt.Printf(" Session ID: %s, User: %s, From: %s\n", sessionID, user, host)
}
}
This Go snippet demonstrates connecting to a Teleport proxy and retrieving a list of currently active sessions. For production use, it is critical to implement robust authentication, typically using mTLS client certificates or a secure token exchange mechanism, rather than the simplified authentication shown here. Further details on authentication methods are available in the Teleport API reference.
Community libraries
Beyond the official SDKs, the Teleport ecosystem benefits from community-contributed libraries and tools. While not officially supported or maintained by Gravitational (the company behind Teleport), these projects can offer additional language bindings, specialized integrations, or utilities that extend Teleport's functionality. Developers often create these to address specific use cases or to provide interfaces for languages not covered by official SDKs.
Examples of community contributions might include:
- Terraform Providers: For managing Teleport resources (users, roles, connectors) as infrastructure as code. The official Teleport Terraform Provider is maintained by Gravitational, but community modules might extend its capabilities.
- Ansible Modules: For automating the deployment and configuration of Teleport components or managing access through Ansible playbooks.
- Client libraries in other languages: Developers might create unofficial clients for languages like Ruby, C#, or Rust to interact with the Teleport API.
- Custom UI components: Frontend developers might build custom dashboards or access portals that leverage the Teleport API via SDKs.
When considering community libraries, it is important to evaluate their maintenance status, security practices, and compatibility with the Teleport version being used. The official Teleport documentation and community forums are good resources for discovering and assessing such projects. Contributions to the open-source Teleport project or related tools can often be found on platforms like GitHub, where the community actively collaborates.
For example, while there is no official C# SDK, developers might create wrapper libraries around the gRPC API directly, leveraging general-purpose gRPC clients available in .NET. This approach is common in ecosystems where direct SDK support isn't available but a well-defined API (like gRPC, as defined by gRPC documentation) allows for custom client generation. Similarly, the Protocol Buffers schema defines the data structures used by Teleport's gRPC API, allowing for client code generation in many languages.