first commit
This commit is contained in:
40
add_start_ssh_agent_on_kde/Was soll passieren.txt
Executable file
40
add_start_ssh_agent_on_kde/Was soll passieren.txt
Executable file
@@ -0,0 +1,40 @@
|
|||||||
|
Ordner anlegen
|
||||||
|
|
||||||
|
mkdir -p ~/.config/autostart-scripts/ ok
|
||||||
|
mkdir -p ~/.config/plasma-workspace/shutdown/ ok
|
||||||
|
mkdir -p ~/.config/plasma-workspace/env/ ok
|
||||||
|
|
||||||
|
Skript erstelle : ~/.config/autostart-scripts/ssh-add.sh
|
||||||
|
|
||||||
|
#! /bin/zsh
|
||||||
|
sleep 10
|
||||||
|
SSH_ASKPASS=/usr/bin/ksshaskpass
|
||||||
|
export SSH_ASKPASS
|
||||||
|
ssh-add ~/.ssh/id_ed25519
|
||||||
|
|
||||||
|
Skript erstellen ~/.config/plasma-workspace/shutdown/ssh-agent-shutdown.sh
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
[ -z "$SSH_AGENT_PID" ] || eval "$(ssh-agent -k)"
|
||||||
|
|
||||||
|
Skript erstelle ~/.config/plasma-workspace/env/ssh-agent-startup.sh
|
||||||
|
|
||||||
|
#!/bin/sh
|
||||||
|
[ -n "$SSH_AGENT_PID" ] || eval "$(ssh-agent -s)"
|
||||||
|
SSH_ASKPASS=/usr/bin/ksshaskpass
|
||||||
|
export SSH_ASKPASS
|
||||||
|
|
||||||
|
Rechte zum ausführen
|
||||||
|
|
||||||
|
chmod +x ~/.config/autostart-scripts/ssh-add.sh
|
||||||
|
chmod +x ~/.config/plasma-workspace/shutdown/ssh-agent-shutdown.sh
|
||||||
|
chmod +x ~/.config/plasma-workspace/env/ssh-agent-startup.sh
|
||||||
|
|
||||||
|
|
||||||
|
sudo vi /etc/profile.d/ksshaskpass.sh
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
export SSH_ASKPASS=/usr/bin/ksshaskpass
|
||||||
|
|
||||||
|
sudo chmod +x /etc/profile.d/ksshaskpass.sh
|
||||||
|
|
||||||
75
add_start_ssh_agent_on_kde/kde_autostart_sshagent_folder_create.py
Executable file
75
add_start_ssh_agent_on_kde/kde_autostart_sshagent_folder_create.py
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
#! /usr/bin/env Python3
|
||||||
|
|
||||||
|
import os, stat
|
||||||
|
|
||||||
|
def create_folder (check_folders = list):
|
||||||
|
exist_dict = []
|
||||||
|
for folder in check_folders:
|
||||||
|
if os.path.isdir(folder) is True:
|
||||||
|
exist_dict.append({"name": folder, "status": "existiert bereits"})
|
||||||
|
else:
|
||||||
|
os.makedirs(folder, exist_ok=True)
|
||||||
|
exist_dict.append({"name": folder, "status": "wurde angelegt"})
|
||||||
|
return exist_dict
|
||||||
|
|
||||||
|
def read_sshkeys(ssh_folder = str):
|
||||||
|
key_liste = []
|
||||||
|
for root, dirs, files in os.walk(ssh_folder, topdown=False):
|
||||||
|
for name in files:
|
||||||
|
FullPATH = str(os.path.join(root, name))
|
||||||
|
if FullPATH.endswith(".pub") is False and FullPATH.endswith("known_hosts") is False and FullPATH.endswith("authorized_keys") is False:
|
||||||
|
key_liste.append(FullPATH)
|
||||||
|
return key_liste
|
||||||
|
|
||||||
|
|
||||||
|
def create_scripts_addkeys(script_folder = str, keys = list):
|
||||||
|
try:
|
||||||
|
script_file = script_folder + "/ssh-add.sh"
|
||||||
|
with open(file=script_file, mode="w") as script:
|
||||||
|
print("""#! /bin/bash\nsleep 10\nSSH_ASKPASS=/usr/bin/ksshaskpass\nexport SSH_ASKPASS\nssh-add {ssh_keys}
|
||||||
|
""".format(ssh_keys=" ".join(keys)), file=script)
|
||||||
|
|
||||||
|
os.chmod(path=script_file, mode=stat.S_IRWXU)
|
||||||
|
except:
|
||||||
|
raise PermissionError("Keine Rechte die Datei " + script_file + " zu erstellen")
|
||||||
|
else:
|
||||||
|
return print(script_file, "erstellt",sep=" ")
|
||||||
|
|
||||||
|
def create_scripts_shutdown(script_folder = str):
|
||||||
|
try:
|
||||||
|
script_file = script_folder + "/ssh-agent-shutdown.sh"
|
||||||
|
with open(file=script_file, mode="w" ) as script:
|
||||||
|
print("""#!/bin/sh\n[ -z "$SSH_AGENT_PID" ] || eval "$(ssh-agent -k)" """, file=script)
|
||||||
|
os.chmod(path=script_file, mode=stat.S_IRWXU)
|
||||||
|
except:
|
||||||
|
raise PermissionError("Keine Rechte die Datei " + script_file + " zu erstellen")
|
||||||
|
else:
|
||||||
|
return print(script_file, "erstellt",sep=" ")
|
||||||
|
|
||||||
|
def create_scripts_startup(script_folder = str):
|
||||||
|
try:
|
||||||
|
script_file = script_folder + "/ssh-agent-shartup.sh"
|
||||||
|
with open(file=script_file, mode="w" ) as script:
|
||||||
|
print("""#!/bin/sh\n[ -z "$SSH_AGENT_PID" ] || eval "$(ssh-agent -s)"\nSSH_ASKPASS=/usr/bin/ksshaskpass\nexport SSH_ASKPASS""", file=script)
|
||||||
|
os.chmod(path=script_file, mode=stat.S_IRWXU)
|
||||||
|
except:
|
||||||
|
raise PermissionError("Keine Rechte die Datei " + script_file + " zu erstellen")
|
||||||
|
else:
|
||||||
|
return print(script_file, "erstellt",sep=" ")
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
kde_folders = [
|
||||||
|
os.environ["HOME"] + "/.config/autostart-scripts",
|
||||||
|
os.environ["HOME"] + "/.config/plasma-workspace/shutdown",
|
||||||
|
os.environ["HOME"] + "/.config/plasma-workspace/env"
|
||||||
|
]
|
||||||
|
|
||||||
|
for test in create_folder(check_folders=kde_folders):
|
||||||
|
print("Folder:" + test["name"] + " status: " + test["status"])
|
||||||
|
#print(read_sshkeys(os.environ["HOME"] + "/.ssh"))
|
||||||
|
create_ssh_script_addkey = create_scripts_addkeys(kde_folders[0], read_sshkeys(os.environ["HOME"] + "/.ssh") )
|
||||||
|
create_ssh_script_shutdown = create_scripts_shutdown(script_folder=kde_folders[1])
|
||||||
|
create_ssh_script_startup = create_scripts_startup(script_folder=kde_folders[2])
|
||||||
|
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user