====== SSH und SCP ====== ===== SSH ===== ^ Befehl ^ Funktion ^ | ssh root@[xxx.xxx.xxx.xxx] | anmelden als root bei xxx.xxx.xxx.xxx | | ssh-keygen | | | ssh-keygen –t rsa | erstellt keys | | ssh-keygen –t rsa –b 2048 | erstellt keys mit 2048 bit | | cat .ssh/id_rsa.pub >> authorized_keys | erstellt authorized_key datei | ===== SCP ===== | scp authorized_keys root@xxx.xxx.xxx.xxx: | schickt authorized_keys an root der IP | | scp [quelle] [benutzer]@[zielip]: | kopiert datei an benutzer der ziel IP | | scp [quelle] [benutzer]@[zielip]:[absoluterZielpfad] | datei an benutzer der ziel IP | ===== Script um Public-Key Hinzuzufügen ===== #!/bin/sh mkdir /etc/skel/.ssh useradd -m -s /bin/bash username echo "ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAp+i1MhaHDsz8WeHvRohWezjoSYCeNNTB4agYP7ZpxiNIspVScHvyErb0YcGFR5vZypy3kETT9HcQKicRdmMIT6GPAOSPDIASDjdfgdjfASDFBz7kZkzgSisifgoeifqIwPbQbPHeR4yLJreXnbGR4xlifkeM5RoogbD5cvLgdwy78aiKPNZMhCheUd4G8srZQUPdGe+TuW8XdFVdzKEhqqNPZSyulHTy6QASJKDHGWEUDFGWZEFWKUEFHZWEIFHWEFBhsdfhsdfgautvG7GQ6mFn+U/u4PxNmmL5RVgdSFoW8J28ePJl6ckFWMi8yLXcZC+01w== username" > /home/username/.ssh/authorized_keys cp /etc/sudoers /etc/sudoers.orig echo "username ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers cp /etc/ssh/sshd_config /etc/ssh/sshd_config.orig grep "PasswordAuthentication yes" /etc/ssh/sshd_config | sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/g' /etc/ssh/sshd_config grep "PermitRootLogin yes" /etc/ssh/sshd_config | sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config service ssh restart