Secure Shell Protocol - For Begginers

Introduction

  • SSH (Secure Shell) is a network protocol that enables secure remote connections between two systems. 
  • System admins use SSH utilities to manage machines, copy, or move files between systems.
  • System admins use SSH utilities to manage machines, copy, or move files between systems.

How to Access a Remote Server

To connect to a remote machine, you need its IP address or name.

ip address:

hostname:

The first time you connect to a host, you’ll see this message:

Type yes and hit enter. You may need to enter your password as well.

Specify a Username for SSH connection

SSH uses the current user when accessing a remote server.

Use a Different Port Number for SSH Connection

  • By default, the SSH server listens for a connection on port 22.
  • If the port setting in the SSH configure file has been changed, you’ll need to specify the port.

Otherwise, you will get this error:

  • To connect to a remote host with a custom SSH port number, use the -p flag.

Generate SSH Keys Using SSH Key-gen

  • To improve the security of SSH connections, generate a key pair with the Key-gen utility.
  • The public key can be shared, while the private key needs to stay secure.
  • SSH key pairs are used to authenticate clients to servers automatically.
  • To use default settings, hit Enter on the prompts for file location and passphrase.

Copy Public SSH Key

  • To use the key pair for SSH authentication, you’ll need to copy the public key to a server.
  • he key is the file id_rsa.pub previously created with SSH keygen utility.

Copy a File Remotely over SSH with  SCP

  • You can securely copy files over the SSH protocol using the SCP tool.
  • Make sure to use the uppercase -P flag if you need to specify the port.

Edit SSH Config File

  • Edit the settings in the sshd_config file to customize SSH server options.
  • Use the editor of your choice to edit the file. You’ll need superuser permissions to make changes. In Linux, we use nano:
  • Enter the sudo password, and the shell opens the file in the editor you used.

Restart SSH service

  • When you make changes to the SSH configuration, you’ll need to restart the service in Linux.
  • Depending on the Linux distro, run one of the commands on the machine where you modified the settings:

🔗 More additional information link

 

Comments