mirror of
https://github.com/Noratrieb/cluelessh.git
synced 2026-01-14 16:35:06 +01:00
more
This commit is contained in:
parent
3f0b367c39
commit
7ac2ef4194
4 changed files with 41 additions and 8 deletions
|
|
@ -9,6 +9,11 @@ use tracing::{debug, trace};
|
|||
|
||||
/// A message to send to the byte stream.
|
||||
pub enum Request {
|
||||
AddIdentity {
|
||||
key_type: String,
|
||||
key_contents: Vec<u8>,
|
||||
key_comment: String,
|
||||
},
|
||||
RemoveAllIdentities,
|
||||
ListIdentities,
|
||||
Sign {
|
||||
|
|
@ -33,6 +38,16 @@ impl Request {
|
|||
pub fn to_bytes(&self) -> Vec<u8> {
|
||||
let mut p = Writer::new();
|
||||
match self {
|
||||
Self::AddIdentity {
|
||||
key_type,
|
||||
key_contents,
|
||||
key_comment,
|
||||
} => {
|
||||
p.u8(numbers::SSH_AGENTC_ADD_IDENTITY);
|
||||
p.string(key_type.as_bytes());
|
||||
p.write(&key_contents);
|
||||
p.string(key_comment.as_bytes());
|
||||
}
|
||||
Self::RemoveAllIdentities => p.u8(numbers::SSH_AGENTC_REMOVE_ALL_IDENTITIES),
|
||||
Self::ListIdentities => p.u8(numbers::SSH_AGENTC_REQUEST_IDENTITIES),
|
||||
Self::Sign {
|
||||
|
|
@ -212,6 +227,21 @@ impl SocketAgentConnection {
|
|||
})
|
||||
}
|
||||
|
||||
pub async fn add_identitity(
|
||||
&mut self,
|
||||
key_type: &str,
|
||||
key_contents: &[u8],
|
||||
key_comment: &str,
|
||||
) -> eyre::Result<()> {
|
||||
self.send(Request::AddIdentity {
|
||||
key_type: key_type.to_owned(),
|
||||
key_contents: key_contents.to_owned(),
|
||||
key_comment: key_comment.to_owned(),
|
||||
})
|
||||
.await?;
|
||||
self.generic_response().await
|
||||
}
|
||||
|
||||
pub async fn remove_all_identities(&mut self) -> eyre::Result<()> {
|
||||
self.send(Request::RemoveAllIdentities).await?;
|
||||
self.generic_response().await
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
-----BEGIN OPENSSH PRIVATE KEY-----
|
||||
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAAAMwAAAAtzc2gtZW
|
||||
QyNTUxOQAAACDpK6HZbsijDttnop9lQyLLGXZi7lS5Hb3bY7DKMDC1vAAAAIhd37wfXd+8
|
||||
HwAAAAtzc2gtZWQyNTUxOQAAACDpK6HZbsijDttnop9lQyLLGXZi7lS5Hb3bY7DKMDC1vA
|
||||
AAAEBCev7X+rchYbMmzYfiyBzZhV/RaZZhYh+MR4/Ktcu0l+krodluyKMO22ein2VDIssZ
|
||||
dmLuVLkdvdtjsMowMLW8AAAAA3V3dQEC
|
||||
-----END OPENSSH PRIVATE KEY-----
|
||||
|
|
@ -1 +0,0 @@
|
|||
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOkrodluyKMO22ein2VDIssZdmLuVLkdvdtjsMowMLW8 uwu
|
||||
|
|
@ -13,6 +13,11 @@ struct Args {
|
|||
|
||||
#[derive(clap::Subcommand, Debug)]
|
||||
enum Subcommand {
|
||||
/// Add a new identity to the agent, SSH_AGENTC_ADD_IDENTITY
|
||||
AddIdentity {
|
||||
/// The path to the private key file
|
||||
identity: PathBuf,
|
||||
},
|
||||
/// Remove all identities from the agent, SSH_AGENTC_REMOVE_ALL_IDENTITIES
|
||||
RemoveAllIdentities,
|
||||
/// List all identities in the agent, SSH_AGENTC_REQUEST_IDENTITIES
|
||||
|
|
@ -46,6 +51,12 @@ async fn main() -> eyre::Result<()> {
|
|||
let mut agent = ssh_agent_client::SocketAgentConnection::from_env().await?;
|
||||
|
||||
match args.command {
|
||||
Subcommand::AddIdentity { identity } => {
|
||||
let file = std::fs::read(&identity)
|
||||
.wrap_err_with(|| format!("reading file {}", identity.display()))?;
|
||||
let _ = file;
|
||||
todo!("we need to parse and decrypt the key...")
|
||||
}
|
||||
Subcommand::RemoveAllIdentities => {
|
||||
agent.remove_all_identities().await?;
|
||||
println!("Removed all identities from the agent");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue