Comments (6)
See blog post that uses a little bit of ssh-rs: http://saidvandeklundert.net/learn/2021-08-06-rust-ssh-cli-tool/
It leverages rpassword to read in a password without showing it externally. Although from my reading, the use of userauth_password
appears to be misleading as this is typically disabled in favor of userauth_keyboard_interactive
to leverage PAM or other auth backends.
Should check out how wezterm-ssh's auth.rs handles this. From reading through it, based on parsing a config, it will try:
- auth agent & pubkey auth if methods include "publickey"
- userauth password if methods include "password" (prompts for it)
- keyboard interactive if methods include "keyboard-interactive"
- Implements a pty that shows the username and instructions, capturing each line as an answer: https://github.com/wez/wezterm/blob/7deb215303ce1a8e64d48f65ef3e0a1d24fc2fbc/wezterm-ssh/examples/ssh.rs#L86
from distant.
From wezterm-ssh, it pulls in auth methods using ssh2's session.auth_methods and does this continuously in a loop when new methods like 2fac show up later.
from distant.
Session and all channels must be in the same thread: alexcrichton/ssh2-rs#36 (comment)
This means the design would be to use set_blocking(false)
to ensure that we can loop through and process incoming and outgoing data. I'm seeing in wezterm-ssh that blocking is enabled for certain operations, so there may be EVEN MORE nuances such at those described in Leaking LIBSSH2_SESSION objects.
As the first attempt, we have a dedicated thread that contains the session and a map of channels. The thread uses message passing to get requests to perform. For each request, we determine if we need to create a new channel (for a process) or use the existing sftp channel (for io).
from distant.
sftp appears to cover everything we need for I/O (including realpath to canonicalize, etc) except for copying files and directories between locations on the remote machine only.
- We could read directories, get paths, read file contents, and then reconstruct using sftp, but that would be really, REALLY expensive
- We detect what system we're on and apply either unix
cp -R <src> <dst>
or windowsxcopy <src> <dst> /s /e
(doc) over an exec call
from distant.
Went with option 2 above, so we're just trying a cp followed by xcopy if that fails. Doing something similar for killing a process where we try kill -9 <PID>
and then taskkill /PID <PID>
.
from distant.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
from distant.
Related Issues (20)
- Write documentation on https://distant.dev/ HOT 1
- Update release artifacts to follow naming distant-<HOST TRIPLE> HOT 2
- Create an embedded, animated SVG for README HOT 2
- Wrong exit code for `distant --version` and `distant --help` HOT 2
- Switch ssh caching to local cache HOT 2
- Zombie process when server terminates that was spawned via `distant launch manager://localhost` HOT 3
- Fix `distant fs set-permissions 'go-w' /path/to/file.txt` HOT 2
- Tailscale SSH: host key mismatch HOT 5
- custom build command for `openssl-sys v0.9.71` HOT 7
- Build interface to extend CLI
- distant-ssh DistantChannel low ability to write files concurrently HOT 3
- Distant client-server hangs when switching networks HOT 1
- Support for OpenBSD HOT 5
- Failed to connect to manager HOT 2
- Exited Unexpectedly: exit code 1 HOT 1
- Create a compilation for `aarch64-linux` HOT 4
- Does not use ssh-agent to retrieve passwords for ssh-keys HOT 3
- GLIBC error? HOT 1
- Cannot connect through SSH: `[Session(-43)] Failed getting banner` HOT 6
- ERROR distant version 0.20.0-alpha.10 incompatible with minimum requirement of 0.20.0 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from distant.