Carane nginstal lan ngatur server SSH ing Debian Linux?

Nginstal lan Testing SSH Server

You will need to be root to do the following…

su

  1. Instal SSH Server

    apt install openssh-server
     

  2. Priksa yen proses server ana. Iki nuduhake nginstal banjur uga.

    ps -A | grep sshd

    output (utawa padha): 1753 ? 00:00:00 sshd

     

  3. Instal Klien SSH kanggo mriksa sambungan SSH Server

    apt install openssh-client

    Nyambung menyang localhost kanggo nyoba sambungan

    ssh localhost

    Uga login nganggo alamat IP antarmuka

    Njaluk Alamat IP

    ip addr

    SSH kanggo alamat ip

    ssh {ipaddress here}
     

Nggayuh SSH Server

Iku apike kanggo ngamanake server SSH dening disallowing ROOT kanggo mlebet lan configuring mlebu mung dening i.e tombol umum. mlebu nggunakake sandhi ora diijini

Ensure to execute the following commands as your user and not as root

  1. Navigasi menyang direktori ngarep pengguna

    cd
     

  2. Priksa yen .ssh ana

    ls -a
     

  3. Yen .ssh ora ana, nggawe

    mkdir .ssh
     

  4. Nyetel ijin folder kanggo 700

    chmod 700 .ssh
     

  5. Nggawe file authorized_keys

    touch ./.ssh/authorized_keys
     

  6. Ganti ijin ing authorized_keys file kanggo 600

    chmod 600 ./.ssh/authorized_keys
     

  7. Bukak file authorized_keys

    nano ./.ssh/authorized_keys
     

  8. Tempel tombol umum menyang berkas

    Sampeyan bisa njaluk tombol umum saka klien SSH. Yen klien punika Windows 10 then it will be in the %USERPROFILE%/.ssh/id_rsa.pub file. If the client is Debian then the public key is ~/.ssh/id_rsa.pub.

    If your public key does not exist, generate it on the client machine

    ssh-keygen -t rsa -C "email@domain.com"
     

  9. Change to root user

    su

  10. Configure your SSH server to accept only public key logins and prevent login for root

    nano /etc/ssh/sshd_config

    Uncomment and/or edit the following lines

    PermitRootLogin no
    StrictModes yes
    PubkeyAuthentication yes
    AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
    PasswordAuthentication no
     

  11. Restart the sshd service

    service sshd restart
     

  12. Try logging in as root from your SSH client using password

    ssh root@{ssh server ip address}

    output: Permission denied (publickey).

     

  13. Try logging in as username from your SSH client using password

    ssh username@{ssh server ip address}

    output: Permission denied (publickey).

     

  14. Try logging in as root from your SSH client using the public key

    ssh root@{ssh server ip address} -i .ssh/id_rsa

    output: Permission denied (publickey).

     

  15. Mlebu minangka jeneng panganggo saka klien SSH nggunakake tombol umum

    ssh username@{ssh server ip address} -i .ssh/id_rsa
     

Yen klien SSH wis alamat IP statis sampeyan bisa uga pengin nimbang Alamat IP Panjenengan saged mlebet ing server SSH.