Skip to content

Commit

Permalink
Fix path generation for sshkeyfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
fsck authored and Trolldemorted committed Feb 26, 2019
1 parent 21cac37 commit 7a70831
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 2 deletions.
133 changes: 133 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ lazy_static = "1.0"
getopts = "0.2"
reqwest = "*"
ssh2 = "*"
dirs = "1.0"
13 changes: 11 additions & 2 deletions src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
extern crate dirs;
use std::io::Write;
use std::fs::File;
use std::fs::OpenOptions;
Expand Down Expand Up @@ -57,7 +58,11 @@ pub fn generate_authorized_key_files(destinations: &[Destination]) -> Result<(),
// append deploy key
let mut deploy_key = String::new();
// TODO: User-configable ssh key
if let Ok(mut deploy_key_file) = File::open("~/.ssh/id_ed25519.pub") {
let mut path = dirs::home_dir().unwrap();
path.push(".ssh");
path.push("id_ed25519.pub");
println!("Loading SSH-pubkeyfile {:?}",path);
if let Ok(mut deploy_key_file) = File::open(path) {
deploy_key_file.read_to_string(&mut deploy_key)?;
write!(authorized_keys_file, "{}", &deploy_key)?
}
Expand Down Expand Up @@ -97,8 +102,12 @@ pub fn generate_authorized_key_files(destinations: &[Destination]) -> Result<(),
}

pub fn load_deploy_keypair() -> Result<(), EnokeysError> {
let mut path = dirs::home_dir().unwrap();
path.push(".ssh");
path.push("id_ed25519");
println!("Loading SSH-keyfile {:?}",path);
// TODO: User-configable ssh key
match File::open("~/.ssh/id_ed25519") {
match File::open(path) {
Ok(_) => Ok(()),
Err(e) => Err(EnokeysError::IOError(e))
}
Expand Down

0 comments on commit 7a70831

Please sign in to comment.