-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #18 from wiktor-k/wiktor/more-cleanup
Clean up a bit the project
- Loading branch information
Showing
7 changed files
with
75 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[codespell] | ||
skip = .cargo,.git,target | ||
ignore-words-list = crate,ser |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
name: CI | ||
|
||
on: [push, pull_request] | ||
on: | ||
pull_request: | ||
push: | ||
tags: | ||
- 'v*' | ||
branches: [ main ] | ||
workflow_dispatch: | ||
|
||
concurrency: | ||
group: ${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
# Use the following command to fix words locally: | ||
# codespell --ignore-words-list "ser,crate,daa,keypair" --skip "*/target,*-sys" --write-changes | ||
check-spelling: | ||
name: Check spelling | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check spelling | ||
uses: codespell-project/actions-codespell@master | ||
with: | ||
ignore_words_list: "ser,crate,daa,keypair" | ||
path: tss-esapi | ||
skip: "*/target,*-sys" | ||
|
||
formatting: | ||
name: Check formatting | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Check formatting | ||
run: cargo fmt --all -- --check | ||
|
||
tests: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Build and test | ||
run: cargo build --verbose --all && cargo test --verbose --all | ||
|
||
lints: | ||
name: Clippy lints | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: actions/checkout@v4 | ||
- name: Check for lints | ||
run: cargo clippy -- -D warnings |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: DCO | ||
|
||
on: pull_request | ||
|
||
jobs: | ||
check: | ||
name: Developer Certificate of Origin | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: tisonkun/[email protected] |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,27 @@ | ||
# ssh-agent-lib | ||
|
||
[![CI](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/ci.yml/badge.svg)](https://github.com/wiktor-k/ssh-agent-lib/actions/workflows/ci.yml) | ||
[![Crates.io](https://img.shields.io/crates/v/ssh-agent-lib)](https://crates.io/crates/ssh-agent-lib) | ||
|
||
A collection of types for writing custom SSH agents. | ||
|
||
This makes it possible to utilize remote keys not supported by the | ||
default OpenSSH agent. | ||
This makes it possible to utilize remote keys not supported by the default OpenSSH agent. | ||
|
||
## Example | ||
|
||
This example starts listening on a Unix socket `connect.sock` and | ||
processes requests. | ||
This example starts listening on a Unix socket `ssh-agent.sock` and processes requests. | ||
|
||
```rust,no_run | ||
use async_trait::async_trait; | ||
use tokio::net::UnixListener; | ||
use ssh_agent_lib::agent::{Session, Agent}; | ||
use ssh_agent_lib::error::AgentError; | ||
use ssh_agent_lib::proto::message::{Message, SignRequest}; | ||
use ssh_agent_lib::proto::message::Message; | ||
#[derive(Default)] | ||
struct MyAgent; | ||
#[async_trait] | ||
#[ssh_agent_lib::async_trait] | ||
impl Session for MyAgent { | ||
async fn handle(&mut self, message: Message) -> Result<Message, AgentError> { | ||
match message { | ||
|
@@ -35,22 +35,34 @@ impl Session for MyAgent { | |
} | ||
} | ||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> { | ||
let agent = MyAgent; | ||
let socket = "connect.sock"; | ||
let _ = std::fs::remove_file(socket); | ||
let socket = UnixListener::bind(socket)?; | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
let socket = "ssh-agent.sock"; | ||
let _ = std::fs::remove_file(socket); // remove the socket if exists | ||
agent.listen(socket).await?; | ||
MyAgent.listen(UnixListener::bind(socket)?).await?; | ||
Ok(()) | ||
} | ||
``` | ||
|
||
For more elaborate example see `examples` directory. | ||
Now, point your OpenSSH client to this socket using `SSH_AUTH_SOCK` environment variable and it will transparently use the agent: | ||
|
||
```sh | ||
SSH_AUTH_SOCK=ssh-agent.sock ssh [email protected] | ||
``` | ||
|
||
For more elaborate example see the `examples` directory or [crates using `ssh-agent-lib`](https://crates.io/crates/ssh-agent-lib/reverse_dependencies). | ||
|
||
## Note | ||
|
||
This library has been forked from | ||
[sekey/ssh-agent.rs](https://github.com/sekey/ssh-agent.rs) as the | ||
upstream seems not be maintained (at least as of 2022). | ||
|
||
# License | ||
|
||
This project is licensed under the [MIT license](https://opensource.org/licenses/MIT). | ||
|
||
## Contribution | ||
|
||
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you shall be licensed as above, without any additional terms or conditions. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters