BY :- shinchan
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
➢ SSH transmits data over encrypted channels, security is at a high level
How to Access a Remote Server
➢ To connect to a remote machine, you need its IP address or name.
IP address:
name:
➢ 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.
sh username@10.0.0.55
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 config 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.
ssh username@hostname_or_ip -p 3322
Generate SSH Keys Using SSH Keygen
➢ To improve the security of SSH connections, generate a key pair with the keygen
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.
ssh-keygen -t rsa
➢ 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.
ssh-copy-id username@hostname_or_ip
Copy a File Remotely over SSH with SCP
➢ You can securely copy files over the SSH protocol using the SCP tool.
scp filename username@hostname_or_ip:/home/test
➢ 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.
sudo nano /etc/ssh/sshd_config
➢ 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:
sudo ssh service restart
sudo sshd service restart