Jinsi ya kufunga na configure SSH server juu ya Debian Linux?
Kufunga na upimaji SSH Server
You will need to be root to do the following…
su
-
Kufunga SSH Server
apt install openssh-server
-
Angalia kama mchakato server ipo. Hii inaonyesha kufunga akaenda vizuri.
ps -A | grep sshdpato (au zinazofanana):
1753 ? 00:00:00 sshd -
Kufunga SSH mteja kuangalia uhusiano SSH Server
apt install openssh-clientUnganisha na kupangisha karibu mtihani uhusiano
ssh localhostPia kuingia kwa IP interface
Kupata Anwani ya IP
ip addrSSH kwa anwani ya 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
-
Angalia kama .ssh ipo
ls -a
-
Kama .ssh haipo, kuunda
mkdir .ssh
-
Kuweka folder ruhusa ya 700
chmod 700 .ssh
-
Kujenga authorized_keys faili
touch ./.ssh/authorized_keys
-
Badilisha ruhusa ya authorized_keys faili 600
chmod 600 ./.ssh/authorized_keys
-
Fungua authorized_keys faili
nano ./.ssh/authorized_keys
-
Bandika muhimu yako ya umma katika faili
Unaweza kupata ufunguo wako wa umma kutoka SSH mteja. Kama mteja ni Windows 10 basi itakuwa katika
%USERPROFILE%/.ssh/id_rsa.pubfile. Kama mteja ni Debian kisha ufunguo wa umma ni~/.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"
-
Change to root user
su -
Configure your SSH server to accept only public key logins and prevent login for root
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}pato:
Permission denied (publickey). -
Try logging in as username from your SSH client using password
ssh username@{ssh server ip address}pato:
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_rsapato:
Permission denied (publickey). -
Log in as username from your SSH client using the public key
ssh username@{ssh server ip address} -i .ssh/id_rsa
If your SSH client has a static IP address then you may want to consider only your IP address can login to the SSH server.
