OpenSSH SSH daemon is called sshd on Linux and used by ssh command. We use ssh and sshd for secure encrypted communications between two untrusted hosts over an insecure network or internet. OpenSSH server listens for connections from clients on TCP port number 22. The server is normally started at boot from /etc/init.d/ssh or /etc/init.d/sshd script. This page explains how to start sshd on Linux using the systemctl command.
Linux start sshd command
- Open the terminal application.
- You must log in as root.
- Use the following commands to start the sshd service:
/etc/init.d/sshd start
OR (for modern Linux distro with systemd)
sudo systemctl start sshd.service - In some cases, the actual script name is different. For example, it is ssh.service on a Debian/Ubuntu Linux. If you are using a CentOS/RHEL/Fedora Linux, use sshd.service name as follows:
/etc/init.d/ssh start
OR (for modern Linux distro with systemd)
sudo systemctl start ssh.service
Start, stop, and restart the OpenSSH server on Linux
You need to execute command as per your Linux distro as described below.
CentOS/RHEL/Fedora Linux
To execute script or sshd service:
sudo systemctl start ssh.service ## <-- Linux start sshd ##
sudo systemctl stop sshd.service ## <-- stop the server ##
sudo systemctl restart sshd.service ## <-- restart the server ##
sudo systemctl status sshd.service ## <-- Get the current status of the server ##
## enable and start sshd at boot time ##
sudo systemctl enable sshd.service
## Is sshd enabled at boot time? ##
sudo systemctl is-enabled sshd.service
Start, Restart and Stop the Server on a CentOS/RHEL/Fedora Linux after installation
A note about SUSE and OpenSUSE Linux
The syntax is same as CentOS/RHEL/Fedora Linux. In other words:
/etc/init.d/sshd {start|stop|restart|status}
OR
sudo systemctl {start|stop|restart|status sshd.service}
Debian/Ubuntu Linux
We can run the sshd service as follows:
sudo systemctl start ssh.service ## <-- Linux start sshd ##
sudo systemctl stop ssh.service ## <-- stop the server ##
sudo systemctl restart ssh.service ## <-- restart the server ##
sudo systemctl status ssh.service ## <-- Get the current status of the server ##
## enable and start sshd at boot time ##
sudo systemctl enable ssh.service
## Is sshd enabled at boot time? ##
sudo systemctl is-enabled ssh.service
HP-UX Unix start/stop/restart sshd
Now, you know start sshd on Linux. But, how do you start sshd on HP-UX? Type following commands as root user:
/sbin/init.d/sshd2 start
/sbin/init.d/sshd2 stop
/sbin/init.d/sshd2 restart
IBM AIX Unix users
Again, ssh and log in as root user and execute the following commands to start, stop, and restart the sshd service:
/etc/rc.d/init.d/sshd start
/etc/rc.d/init.d/sshd stop
/etc/rc.d/init.d/sshd restart
Conclusion
The sshd service starts automatically on Linux after installation and typically enabled and installed during server set up. A script or unit file is installed too, which you can use to start, stop, restart, and find the status of the sshd service. See OpenSSH home page and docs here and the following pages:
- OpenSSH Server Best Security Practices
- keychain: Set Up Secure Passwordless SSH Access For Backup Scripts
- sshpass: Login To SSH Server / Provide SSH Password Using A Shell Script
- How To Setup SSH Keys on a Linux / Unix System
- How to upload ssh public key to as authorized_key using Ansible DevOPS tool
- SSH Public Key Based Authentication on a Linux/Unix server
🐧 0 comments... add one ↓
Category | List of Unix and Linux commands |
---|---|
File Management | cat |
Firewall | Alpine Awall • CentOS 8 • OpenSUSE • RHEL 8 • Ubuntu 16.04 • Ubuntu 18.04 • Ubuntu 20.04 |
Network Utilities | dig • host • ip • nmap |
OpenVPN | CentOS 7 • CentOS 8 • Debian 10 • Debian 8/9 • Ubuntu 18.04 • Ubuntu 20.04 |
Package Manager | apk • apt |
Processes Management | bg • chroot • cron • disown • fg • jobs • killall • kill • pidof • pstree • pwdx • time |
Searching | grep • whereis • which |
User Information | groups • id • lastcomm • last • lid/libuser-lid • logname • members • users • whoami • who • w |
WireGuard VPN | Alpine • CentOS 8 • Debian 10 • Firewall • Ubuntu 20.04 |