هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
RHEL, Rocky, Alma, Fedora:
dnf -y install openssh-server
systemctl enable --now sshd
firewall-cmd --permanent --add-service=ssh
firewall-cmd --reloadUbuntu, Debian:
apt-get update && apt-get install -y openssh-server
systemctl enable --now ssh
ufw allow OpenSSHStep by step
- Check if it is already there and running:
(The service is sshd on RHEL and ssh on Ubuntu.)
- Install the package
openssh-server(commands above). The clientsshis a different package (openssh-clients/openssh-client) and is almost always installed. - Start it now and at every boot with
systemctl enable --now. On Ubuntu 22.10 and newer,ssh.socketlistens on port 22 and startsssh.serviceat the first connection — that is normal. - Open the firewall for port 22 — on the server and in the cloud security group or network firewall if there is one.
- Find the address to connect to:
- Log in from another machine:
ssh admin@192.0.2.10
The authenticity of host '192.0.2.10 (192.0.2.10)' can't be established.
ED25519 key fingerprint is SHA256:Qx1v…
Are you sure you want to continue connecting (yes/no/[fingerprint])? yesCompare the fingerprint with the one on the server (ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub) before you type yes.
Check that it worked
Common problems
| Problem | Cause | Fix |
|---|---|---|
Connection refused | The service is not running, or listens on another port. | systemctl status sshd; ss -ltnp for the port. |
Connection timed out | Firewall or cloud security group blocks port 22. | Open the ssh service; check the security group / NACL. |
Permission denied (publickey) | Password login is off and your key is not on the server. | See "How to log in with SSH keys"; use the cloud console to add the key. |
Service fails: sshd: no hostkeys available | Host keys were deleted (for example in a template). | ssh-keygen -A, then start the service again. |
Unit sshd.service not found on Ubuntu | The name is ssh there. | systemctl status ssh. |
REMOTE HOST IDENTIFICATION HAS CHANGED | The server was rebuilt (new host keys) — or an attack. | Check with the server owner, then ssh-keygen -R 192.0.2.10. |
Go further
- The full guide with hardening (keys only, no root, allowed groups): Install and harden the OpenSSH server.
- Next how-tos: Log in with SSH keys, Open a port in the firewall, Copy files between servers, Harden the SSH server.
- Command pages: sshd, ssh, systemctl, firewall-cmd.
- Learn it for the exam: RH124 — Configure and secure SSH, RHCSA — SSH. Practise: Lab: SSH.
2SSH gives "Connection timed out", the service is running. What do you check?
The firewall on the server and the cloud security group for port 22.