shell method
Future<SSHSession>
shell({
- SSHPtyConfig? pty = const SSHPtyConfig(),
- Map<
String, String> ? environment,
Start a shell on the remote side. Returns a SSHSession that can be used to read, write and control the pty on the remote side.
Implementation
Future<SSHSession> shell({
SSHPtyConfig? pty = const SSHPtyConfig(),
Map<String, String>? environment,
}) async {
await _authenticated.future;
final channelController = await _openSessionChannel();
if (environment != null) {
for (var pair in environment.entries) {
channelController.sendEnv(pair.key, pair.value);
}
}
if (pty != null) {
final ok = await channelController.sendPtyReq(
terminalType: pty.type,
terminalWidth: pty.width,
terminalHeight: pty.height,
terminalPixelWidth: pty.pixelWidth,
terminalPixelHeight: pty.pixelHeight,
);
if (!ok) {
channelController.close();
throw SSHChannelRequestError('Failed to start pty');
}
}
if (!await channelController.sendShell()) {
channelController.close();
throw SSHChannelRequestError('Failed to start shell');
}
return SSHSession(channelController.channel);
}