fix: now deals with the correct path for the old ssh accounts

This commit is contained in:
silver 2023-08-24 18:54:22 +01:00
parent 32d693fa8c
commit ce471ad39a
6 changed files with 23 additions and 9 deletions

1
.gitignore vendored
View file

@ -7,5 +7,6 @@
result
/result
tmp/
tmp.*
*.csv

View file

@ -56,7 +56,7 @@
DATABASE = "database.db";
CSV = "wolves.csv";
HOST_PORT = cfg.host_port;
SSH_ROOT = "/skynet_old/home";
SSH_ROOT = "skynet_old";
# Email stuff
EMAIL_SMTP = cfg.mail.host;

18
scripts/grab_keys.sh Normal file
View file

@ -0,0 +1,18 @@
#!/bin/bash
from="./skynet_old/home"
to="./home_tmp"
find $from -maxdepth 3 -name "authorized_keys" -type f > tmp2
while IFS= read -r path_old
do
echo "From: $path_old"
path_new="${path_old/"$from"/"$to"}"
echo "To: $path_new"
path_dir="${path_new/authorized_keys/}"
mkdir -p "$path_dir"
cp "$path_old" "$path_new"
done < tmp2
rm tmp2
chmod -R skynet_ldap_backend $to

View file

@ -1,3 +0,0 @@
# --- BEGIN PVE ---
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBHbsOjxIcLasz+CHA8gUg1pvc8dPHwMKdWoIwNvPxLp Desktop_WSL
# --- END PVE ---

View file

@ -206,7 +206,7 @@ pub fn get_config() -> Config {
mail_smtp: "".to_string(),
mail_user: "".to_string(),
mail_pass: "".to_string(),
ssh_root: "/skynet_old/home".to_string(),
ssh_root: "skynet_old".to_string(),
};
if let Ok(x) = env::var("LDAP_HOST") {

View file

@ -455,8 +455,7 @@ pub mod ssh {
let config = &req.state().config;
// check if <root>/<user>/.ssh/authorized_keys exists
let root = &config.ssh_root;
let path = format!("{}/{}/.ssh/authorized_keys", root, user);
let path = format!("{}/{}/{}/.ssh/authorized_keys", &config.home, &config.ssh_root, user);
let mut keys = vec![];
if fs::read_to_string(&path).is_ok() {
if let Ok(x) = AuthorizedKeys::read_file(path) {
@ -545,8 +544,7 @@ pub mod ssh {
// check if <root>/<user>/.ssh/authorized_keys exists
//let root = "/skynet_old";
let root = ".";
let path = format!("{}/{}/.ssh/authorized_keys", root, user);
let path = format!("{}/{}/{}/.ssh/authorized_keys", &config.home, &config.ssh_root, user);
let sig = match SshSig::from_pem(auth_signed) {
Ok(x) => x,