Secure Shell (SSH) is a TCP/IP service that provides a secure mechanism for remotely logging into one system over either a local
network or the internet from another system. SSH also provides the ability to transfer files between remote systems.
When a user logs into a remote system using SSH, they receive a command prompt allowing them to enter commands on the remote
system as if they were sitting at the remote system and had opened a terminal session.
Wikipedia: Secure Shell
In order for a system to accept SSH connections the system must first be running the SSH server. By default, many Linux distributions installs the SSH server.
To check if it is installed and running use the following command:
# systemctl status sshd
● sshd.service - OpenSSH server daemon Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2017-07-08 12:04:57 +05; 4h 14min ago Docs: man:sshd(8) man:sshd_config(5) Main PID: 978 (sshd) CGroup: /system.slice/sshd.service └─978 /usr/sbin/sshd -D Jul 08 12:04:56 vm1co7 systemd: Starting OpenSSH server daemon... Jul 08 12:04:57 vm1co7 sshd: Server listening on 0.0.0.0 port 22. Jul 08 12:04:57 vm1co7 sshd: Server listening on :: port 22. Jul 08 12:04:57 vm1co7 systemd: Started OpenSSH server daemon.
SSH can be used to log into your system from a remote system. It is also possible to test that the SSH server is running and accessible from the local machine. SSH connections are established using the
ssh client utility.
To connect from your local machine back to itself use the following command:
# ssh -l username ipaddress
Where username is the name of the user you wish to log in as and ipaddress is the IP address of your system. You can also substitute the hostname of the system in place of the IP address.
To connect from a remote system perform the same steps above using either the IP address or host name of the remote host to which you wish to connect. Enter your password when prompted and you will find yourself logged into the remote system.
The SSH service provides a mechanism for securely copying files to and from a remote system. Copying is performed using the
To copy a file to a directory on a remote system, execute the following command:
# scp demo.txt username@remoteip:/home/username
Where demo.txt is the name of the file to be uploaded to the remote system, username is the name of user account to be used to log into the remote system, remoteip is replaced by the real IP address or hostname of the system and /home/username represents the directory into which the file should be copied.
The above file could similarly be copied from the remote system to the local system as follows:
# scp username@remoteip:/home/username/demo.txt .
The above command will copy the remote file to the current directory on the local system.