Ubuntu: install / start/stop enable/disable ssh server 2
OpenSSH
is a freely available version of the Secure Shell (SSH)
protocol family of tools for remotely controlling, or transferring files between, computers.
Install SSH server
To install the openssh-server
on an Ubuntu
, you need execute the following command as root or using sudo
:
apt-get install openssh-server -y;
Disable SSH server
To disable the ssh
service, execute the following command as root or using sudo
:
systemctl disable ssh;
Enable SSH server
To enable the ssh
service, execute the following command as root or using sudo
:
systemctl enable ssh;
Stop SSH server
To stop (or deactivate) the ssh
service, execute the following command as root or using sudo
:
systemctl stop ssh;
Start SSH server
To start (or activate) the ssh
service, execute the following command as root or using sudo
:
systemctl start ssh;
Status of SSH server
To check the status of the ssh
service, execute the following command as root or using sudo
:
systemctl status ssh;
CONCEPTS
In a nutshell:
enabled
is a service that is configured to start when the system bootsdisabled
is a service that is configured to not start when the system bootsactive
is a service that is currently runninginactive
is a service that is currently stopped and may be disabled, but it can be started and become active
In much more detail:
systemd provides a dependency system between various entities called “units” of 12 different types. Units encapsulate various objects that are relevant for system boot-up and maintenance. The majority of units are configured in unit configuration files, whose syntax and basic set of options is described in systemd.unit(5), however some are created automatically from other configuration, dynamically from system state or programmatically at runtime. Units may be “active” (meaning started, bound, plugged in, …, depending on the unit type, see below), or “inactive” (meaning stopped, unbound, unplugged, …), as well as in the process of being activated or deactivated, i.e. between the two states (these states are called “activating”, “deactivating”). A special “failed” state is available as well, which is very similar to “inactive” and is entered when the service failed in some way (process returned error code on exit, or crashed, or an operation timed out). If this state is entered, the cause will be logged, for later reference. Note that the various unit types may have a number of additional substates, which are mapped to the five generalized unit states described here.
— From man systemd