Si për të instaluar dhe konfiguruar server SSH për Debian Linux?
Instalimi dhe testimi Server SSH
You will need to be root to do the following…
su
-
Install SSH Server
apt install openssh-server
-
Kontrolloni nëse procesi server ekziston. Kjo tregon instaloni shkoi mirë.
ps -A | grep sshdprodhim (ose të ngjashme):
1753 ? 00:00:00 sshd -
Install klient SSH për të kontrolluar lidhjen SSH Server
apt install openssh-clientLidhu tek pritësi lokal për të testuar lidhjen
ssh localhostGjithashtu identifikoheni me ndërfaqe adresë IP
Get IP Address
ip addrSSH në adresën IP
ssh {ipaddress here}
Securing the SSH Server
It is a good idea to secure the SSH server by disallowing root to login and configuring login only by public key i.e. login using passwords is not allowed
Ensure to execute the following commands as your user and not as root
-
Navigate to the user home directory
cd
-
Kontrolloni nëse ekziston .ssh
ls -a
-
Nëse .ssh nuk ekziston, krijuar atë
mkdir .ssh
-
Set leje dosje për 700
chmod 700 .ssh
-
Krijo authorized_keys file
touch ./.ssh/authorized_keys
-
Ndryshimi leje në authorized_keys dosjen në 600
chmod 600 ./.ssh/authorized_keys
-
Hapni authorized_keys file
nano ./.ssh/authorized_keys
-
Paste kyç tuaj publik në dosjen
Ju mund të merrni kyç tuaj publik nga klienti SSH. Nëse klienti është Windows 10 atëherë ajo do të jetë në
%USERPROFILE%/.ssh/id_rsa.pubskedar. Nëse klienti është Debian atëherë çelësi publik është~/.ssh/id_rsa.pub.Nëse çelësi juaj publike nuk ekziston, gjenerojë atë në makinë klientit
ssh-keygen -t rsa -C "email@domain.com"
-
Change to root user
su -
Konfiguro serverin tuaj SSH për të pranuar vetëm hyrje kryesore publike dhe për të parandaluar login për rrënjë
nano /etc/ssh/sshd_configUncomment and/or edit the following lines
PermitRootLogin no
StrictModes yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys .ssh/authorized_keys2
PasswordAuthentication no
-
Restart the sshd service
service sshd restart
-
Try logging in as root from your SSH client using password
ssh root@{ssh server ip address}prodhim:
Permission denied (publickey). -
Try logging in as username from your SSH client using password
ssh username@{ssh server ip address}prodhim:
Permission denied (publickey). -
Try logging in as root from your SSH client using the public key
ssh root@{ssh server ip address} -i .ssh/id_rsaprodhim:
Permission denied (publickey). -
Identifikohu si emrin nga klientit tuaj SSH duke përdorur çelësin publik
ssh username@{ssh server ip address} -i .ssh/id_rsa
Nëse klienti juaj SSH ka një adresë statike IP, atëherë ju mund të dëshirojnë të marrin në konsideratë vetëm IP adresën tuaj mund të hyni brënda për të server SSH.
