Skip to content

Commit 378dab8

Browse files
committed
Clarify in the docs that PermitUserEnvironment is needed to pass environment variables along
1 parent 7bbd3f0 commit 378dab8

File tree

2 files changed

+15
-17
lines changed

2 files changed

+15
-17
lines changed

README.md

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -74,20 +74,17 @@ An example of how pty model can be used:
7474

7575
```swift
7676
try await client.withPTY(
77-
SSHChannelRequestEvent.PseudoTerminalRequest(
78-
wantReply: true,
79-
term: "xterm",
80-
terminalCharacterWidth: 80,
81-
terminalRowHeight: 24,
82-
terminalPixelWidth: 0,
83-
terminalPixelHeight: 0,
84-
terminalModes: .init([.ECHO: 1])
85-
),
86-
environment: [SSHChannelRequestEvent.EnvironmentRequest(wantReply: true, name: "LANG", value: "en_US.UTF-8")]) {
87-
88-
ttyOutput, ttyStdinWriter in
89-
90-
...do something...
77+
SSHChannelRequestEvent.PseudoTerminalRequest(
78+
wantReply: true,
79+
term: "xterm",
80+
terminalCharacterWidth: 80,
81+
terminalRowHeight: 24,
82+
terminalPixelWidth: 0,
83+
terminalPixelHeight: 0,
84+
terminalModes: .init([.ECHO: 1])
85+
)
86+
) { ttyOutput, ttyStdinWriter in
87+
...do something...
9188
}
9289
```
9390

Sources/Citadel/TTY/Client/TTY.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import Foundation
22
import Logging
33
import NIO
4-
import NIOSSH
4+
@preconcurrency import NIOSSH
55
import NIOConcurrencyHelpers
6+
67
/// Represents an error that occurred while processing TTY standard error output
78
public struct TTYSTDError: Error {
89
/// The error message as a raw byte buffer
@@ -232,7 +233,7 @@ extension SSHClient {
232233
/// Executes a command on the remote server and returns a stream of its output
233234
/// - Parameters:
234235
/// - command: The command to execute on the remote server
235-
/// - environment: Array of environment variables to set for the command
236+
/// - environment: Array of environment variables to set for the command. This requires `PermitUserEnvironment` to be enabled in your OpenSSH server's configuration.
236237
/// - inShell: Whether to execute the command within a shell context. Defaults to false
237238
/// - Returns: An async stream that yields command output as it becomes available
238239
/// - Throws: CommandFailed if the command exits with non-zero status
@@ -342,7 +343,7 @@ extension SSHClient {
342343
/// Creates a pseudo-terminal (PTY) session and executes the provided closure with input/output streams
343344
/// - Parameters:
344345
/// - request: PTY configuration parameters
345-
/// - environment: Array of environment variables to set for the PTY session
346+
/// - environment: Array of environment variables to set for the PTY session. This requires `PermitUserEnvironment` to be enabled in your OpenSSH server's configuration.
346347
/// - perform: Closure that receives TTY input/output streams and performs terminal operations
347348
/// - Throws: Any errors that occur during PTY setup or operation
348349
@available(macOS 15.0, *)

0 commit comments

Comments
 (0)