ssh: allow wezterm ssh -v to log verbose diagnostics to stderr
Feels generally useful
This commit is contained in:
1 parent
81aaab2c1f
commit
b8ff61da5b
3 files changed
+27
-2
No files matched your search
@@ -76,6 +76,12 @@ pub struct SshCommand {
|
||||
number_of_values = 1)]
|
||||
pub config_override: Vec<(String, String)>,
|
||||
|
||||
/// Enable verbose ssh protocol tracing.
|
||||
/// The trace information is printed to the stderr stream of
|
||||
/// the process.
|
||||
#[structopt(short = "v")]
|
||||
pub verbose: bool,
|
||||
|
||||
/// Instead of executing your shell, run PROG.
|
||||
/// For example: `wezterm ssh user@host -- bash -l` will spawn bash
|
||||
/// as if it were a login shell.
|
||||
|
||||
@@ -115,6 +115,9 @@ async fn async_run_ssh(opts: SshCommand) -> anyhow::Result<()> {
|
||||
}
|
||||
.to_string(),
|
||||
);
|
||||
if opts.verbose {
|
||||
ssh_config.insert("wezterm_ssh_verbose".to_string(), "true".to_string());
|
||||
}
|
||||
|
||||
if let Some(username) = &opts.user_at_host_and_port.username {
|
||||
ssh_config.insert("user".to_string(), username.to_string());
|
||||
|
||||
@@ -104,7 +104,15 @@ impl SessionInner {
|
||||
.context("notifying user of banner")?;
|
||||
|
||||
let sess = libssh::Session::new()?;
|
||||
// sess.set_option(libssh::SshOption::LogLevel(libssh::LogLevel::Packet))?;
|
||||
if self
|
||||
.config
|
||||
.get("wezterm_ssh_verbose")
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("false")
|
||||
== "true"
|
||||
{
|
||||
sess.set_option(libssh::SshOption::LogLevel(libssh::LogLevel::Packet))?;
|
||||
}
|
||||
sess.set_option(libssh::SshOption::Hostname(hostname.clone()))?;
|
||||
sess.set_option(libssh::SshOption::User(Some(user)))?;
|
||||
sess.set_option(libssh::SshOption::Port(port))?;
|
||||
@@ -221,7 +229,15 @@ impl SessionInner {
|
||||
};
|
||||
|
||||
let mut sess = ssh2::Session::new()?;
|
||||
// sess.trace(ssh2::TraceFlags::all());
|
||||
if self
|
||||
.config
|
||||
.get("wezterm_ssh_verbose")
|
||||
.map(|s| s.as_str())
|
||||
.unwrap_or("false")
|
||||
== "true"
|
||||
{
|
||||
sess.trace(ssh2::TraceFlags::all());
|
||||
}
|
||||
sess.set_blocking(true);
|
||||
sess.set_tcp_stream(tcp);
|
||||
sess.handshake()
|
||||
|
||||
Reference in new issue
Block a user