Skip to content

SSH Login ohne Passwort

Angeheftet Linux
  • Wird Zeit das man den Artikel hier mal vernünftig macht, habe deswegen gestern drei Stunden verplempert, weil vermutlich wg. der Hitze, der Groschen nicht fallen wollte 🙂

    Server

    Installation des Dienstes

    apt install openssh-server
    

    In der Datei /etc/ssh/sshd_config wird der SSH-Dienst gesteuert. Die Zeile, die uns interessiert.

    PermitRootLogin without-password
    

    Was bedeutet das jetzt?

    • without-password Der Passwort-Login für Root ist deaktiviert, dann kann man sich nur mittels SSH-Key einloggen, wenn dieser hinterlegt wurde.

    PermitRootLogin
    Specifies whether root can log in using ssh(1). The argument must be “yes”,
    “without-password”, “forced-commands-only”, or “no”. The default is “yes”.

    If this option is set to “without-password”, password authentication is disabled for
    root.

    If this option is set to “forced-commands-only”, root login with public key
    authentication will be allowed, but only if the command option has been specified
    (which may be useful for taking remote backups even if root login is normally not
    allowed). All other authentication methods are disabled for root.

    If this option is set to “no”, root is not allowed to log in.

    Quelle: http://manpages.ubuntu.com/manpages/trusty/en/man5/sshd_config.5.html

    Datei bearbeiten und dann den Dienst einmal neustarten

    service sshd restart
    

    oder

     /etc/init.d/ssh restart
    

    Client

    Wir erzeugen einen Key mit

    ssh-keygen -t rsa -b 4096
    

    Dann kopieren wir diesen Key auf das Zielsystem. Das geht aber nur, wenn

    PermitRootLogin yes
    

    steht. Also vorher auf dem Server umstellen und den Dienst neustarten!

    Key kopieren

    cat .ssh/id_rsa.pub | ssh username@domain.com 'cat >> .ssh/authorized_keys'
    

    Fertig!

    Danach auf dem Server wieder auf

    PermitRootLogin without-password
    

    umstellen. Ganz wichtig!!

  • Wenn das mal nicht geht, ist der Ordner .ssh auf dem Ziel/Quelle nicht vorhanden.

    Dann auf dem Ziel/Quelle

    ssh-keygen -t rsa
    

    ausführen, danach geht es.

  • Ich habe heute den Ursprungsbeitrag mal vernünftig aktualisiert, weil ich gestern drei Stunden bei dem Testen von sshfs verplempert habe. Zu sshfs kommt auch noch ein Beitrag 😉

  • Wie ihr ja wisst, benutze ich das Forum hier auch gerne als Notizbuch 🙂 Also mal wieder was hier notieren. Mein Windows Systemadmin sagte mir heute, das es auch folgendes gibt

    # ssh-keygen -t ed25519
    Generating public/private ed25519 key pair.
    Enter file in which to save the key (/root/.ssh/id_ed25519): /tmp/ed
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /tmp/ed
    Your public key has been saved in /tmp/ed.pub
    The key fingerprint is:
    SHA256:D33HCTW7Dy0p5kQdFTkPudx1PQh0EHFgkBvxy8KwhGM root@frank-ms7c92
    The key's randomart image is:
    +--[ED25519 256]--+
    |         o=O*o=+=|
    |      .  oo o+oB+|
    |     E o  o.o.o+*|
    |    . o +o...oo=o|
    |       .So.o= O .|
    |         o.= o + |
    |          . .   .|
    |                 |
    |                 |
    +----[SHA256]-----+
    

    Der Key liegt nur in /tmp kopieren lohnt also nicht 🙂

    Ob das jetzt die Zukunft ist, kann ich nicht beantworten. Ich wollte es aber hier mal festhalten, weil es wohl mittlerweile auch von vielen Projekten benutzt wird.

  • FrankMF FrankM hat am auf dieses Thema verwiesen

  • RISC-V

    VisionFive 2
    1
    0 Stimmen
    1 Beiträge
    63 Aufrufe
    Niemand hat geantwortet
  • 0 Stimmen
    1 Beiträge
    105 Aufrufe
    Niemand hat geantwortet
  • 10G

    Linux
    2
    0 Stimmen
    2 Beiträge
    125 Aufrufe
    FrankMF

    Bedingt durch ein paar Probleme mit der Forensoftware, habe ich einen kleinen Datenverlust erlitten. Dazu gehören auch hier einige Beiträge. Dann versuche ich das mal zu rekonstruieren.

    Oben hatten wir das SFP+ Modul ja getestet. Als nächsten Schritt habe ich die ASUS XG-C100F 10G SFP+ Netzwerkkarte in meinen Hauptrechner verbaut.

    20211028_162455_ergebnis.jpg

    Die Verbindung zum Zyxel Switch erfolgt mit einem DAC-Kabel. Im Video zum Zyxel Switch wurde schön erklärt, das die DAC Verbindung stromsparender als RJ45 Adapter sind. Somit fiel die Wahl auf die DAC Verbindungen. Hier nochmal das Video.

    So sieht so ein DAC Verbindungskabel aus. Die SFP+ Adapter sind direkt daran montiert.

    20211028_170118_ergebnis.jpg

    ethtool root@frank-MS-7C37:/home/frank# ethtool enp35s0 Settings for enp35s0: Supported ports: [ FIBRE ] Supported link modes: 100baseT/Full 1000baseT/Full 10000baseT/Full 2500baseT/Full 5000baseT/Full Supported pause frame use: Symmetric Receive-only Supports auto-negotiation: Yes Supported FEC modes: Not reported Advertised link modes: 100baseT/Full 1000baseT/Full 10000baseT/Full 2500baseT/Full 5000baseT/Full Advertised pause frame use: Symmetric Advertised auto-negotiation: Yes Advertised FEC modes: Not reported Speed: 10000Mb/s Duplex: Full Port: FIBRE PHYAD: 0 Transceiver: internal Auto-negotiation: on Supports Wake-on: pg Wake-on: g Current message level: 0x00000005 (5) drv link Link detected: yes iperf3 ----------------------------------------------------------- Server listening on 5201 ----------------------------------------------------------- Accepted connection from 192.168.3.207, port 44570 [ 5] local 192.168.3.213 port 5201 connected to 192.168.3.207 port 44572 [ ID] Interval Transfer Bitrate Retr Cwnd [ 5] 0.00-1.00 sec 1.10 GBytes 9.43 Gbits/sec 46 1.59 MBytes [ 5] 1.00-2.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.60 MBytes [ 5] 2.00-3.00 sec 1.10 GBytes 9.42 Gbits/sec 3 1.60 MBytes [ 5] 3.00-4.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.60 MBytes [ 5] 4.00-5.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.61 MBytes [ 5] 5.00-6.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.63 MBytes [ 5] 6.00-7.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.63 MBytes [ 5] 7.00-8.00 sec 1.09 GBytes 9.41 Gbits/sec 0 1.68 MBytes [ 5] 8.00-9.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.68 MBytes [ 5] 9.00-10.00 sec 1.10 GBytes 9.42 Gbits/sec 0 1.68 MBytes [ 5] 10.00-10.02 sec 22.5 MBytes 9.45 Gbits/sec 0 1.68 MBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bitrate Retr [ 5] 0.00-10.02 sec 11.0 GBytes 9.42 Gbits/sec 49 sender
  • ZFS - One Disk Pool -> Mirror Pool

    Linux
    1
    0 Stimmen
    1 Beiträge
    139 Aufrufe
    Niemand hat geantwortet
  • Wireguard - nmcli

    Wireguard
    1
    0 Stimmen
    1 Beiträge
    445 Aufrufe
    Niemand hat geantwortet
  • 1 Stimmen
    1 Beiträge
    203 Aufrufe
    Niemand hat geantwortet
  • LUKS verschlüsselte Platte mounten

    Linux
    2
    0 Stimmen
    2 Beiträge
    647 Aufrufe
    FrankMF

    So, jetzt das ganze noch einen Ticken komplizierter 🙂

    Ich habe ja heute, für eine Neuinstallation von Ubuntu 20.04 Focal eine zweite NVMe SSD eingebaut. Meinen Bericht zu dem Thema findet ihr hier. Aber, darum soll es jetzt hier nicht gehen.

    Wir haben jetzt zwei verschlüsselte Ubuntu NVMe SSD Riegel im System. Jetzt klappt die ganze Sache da oben nicht mehr. Es kommt immer einen Fehlermeldung.

    unbekannter Dateisystemtyp „LVM2_member“.

    Ok, kurz googlen und dann findet man heraus, das es nicht klappen kann, weil beide LVM Gruppen, den selben Namen benutzen.

    root@frank-MS-7C37:/mnt/crypthome/root# vgdisplay --- Volume group --- VG Name vgubuntu2 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <464,53 GiB PE Size 4,00 MiB Total PE 118919 Alloc PE / Size 118919 / <464,53 GiB Free PE / Size 0 / 0 VG UUID lpZxyv-cNOS-ld2L-XgvG-QILa-caHS-AaIC3A --- Volume group --- VG Name vgubuntu System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size <475,71 GiB PE Size 4,00 MiB Total PE 121781 Alloc PE / Size 121781 / <475,71 GiB Free PE / Size 0 / 0 VG UUID jRYTXL-zjpY-lYr6-KODT-u0LJ-9fYf-YVDna7

    Hier oben sieht man das schon mit geändertem Namen. Der VG Name muss unterschiedlich sein. Auch dafür gibt es ein Tool.

    root@frank-MS-7C37:/mnt/crypthome/root# vgrename --help vgrename - Rename a volume group Rename a VG. vgrename VG VG_new [ COMMON_OPTIONS ] Rename a VG by specifying the VG UUID. vgrename String VG_new [ COMMON_OPTIONS ] Common options for command: [ -A|--autobackup y|n ] [ -f|--force ] [ --reportformat basic|json ] Common options for lvm: [ -d|--debug ] [ -h|--help ] [ -q|--quiet ] [ -v|--verbose ] [ -y|--yes ] [ -t|--test ] [ --commandprofile String ] [ --config String ] [ --driverloaded y|n ] [ --nolocking ] [ --lockopt String ] [ --longhelp ] [ --profile String ] [ --version ] Use --longhelp to show all options and advanced commands.

    Das muss dann so aussehen!

    vgrename lpZxyv-cNOS-ld2L-XgvG-QILa-caHS-AaIC3A vgubuntu2 ACHTUNG Es kann zu Datenverlust kommen, also wie immer, Hirn einschalten!

    Ich weiß, das die erste eingebaute Platte mit der Nummer /dev/nvme0n1 geführt wird. Die zweite, heute verbaute, hört dann auf den Namen /dev/nvme1n1. Die darf ich nicht anpacken, weil sonst das System nicht mehr startet.

    /etc/fstab

    # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> /dev/mapper/vgubuntu-root / ext4 errors=remount-ro 0 1 # /boot was on /dev/nvme1n1p2 during installation UUID=178c7e51-a1d7-4ead-bbdf-a956eb7b754f /boot ext4 defaults 0 2 # /boot/efi was on /dev/nvme0n1p1 during installation UUID=7416-4553 /boot/efi vfat umask=0077 0 1 /dev/mapper/vgubuntu-swap_1 none swap sw 0 0

    Jo, wenn jetzt die Partition /dev/mapper/vgubuntu2-root / anstatt /dev/mapper/vgubuntu-root / heißt läuft nichts mehr. Nur um das zu verdeutlichen, auch das könnte man problemlos reparieren. Aber, ich möchte nur warnen!!

    Nachdem die Änderung durchgeführt wurde, habe ich den Rechner neugestartet. Puuh, Glück gehabt, richtige NVMe SSD erwischt 🙂

    Festplatte /dev/mapper/vgubuntu2-root: 463,58 GiB, 497754832896 Bytes, 972177408 Sektoren Einheiten: Sektoren von 1 * 512 = 512 Bytes Sektorgröße (logisch/physikalisch): 512 Bytes / 512 Bytes E/A-Größe (minimal/optimal): 512 Bytes / 512 Bytes

    Nun können wir die Platte ganz normal, wie oben beschrieben, mounten. Nun kann ich noch ein paar Dinge kopieren 😉

  • Nextcloud ohne https lokal nutzen!?

    Verschoben Nextcloud
    1
    0 Stimmen
    1 Beiträge
    728 Aufrufe
    Niemand hat geantwortet