SSH

 SSH (Secure Shell) is a network protocol that enables secure remote connections between two systems.

  1. Connect remote machine using IP address or machine name: The remote server can be connected with local user name using either host name or IP address
ssh <host-name> or <ip-address>

Example:
ssh 192.111.66.100
ssh test.remoteserver.com
  1. Connect remote machine using username: It is also possible specify a user for an SSH connection.
ssh username@hostname_or_ip-address

Example:
ssh john@192.0.0.22
ssh john@test.remoteserver.com
  1. :Connect remote machine using custom port By default, the SSH server listens for a connection on port 22. But you can also specify the custom port.
ssh <host-name> or <ip-address> -p port_number

Example:
ssh test.remoteserver.com -p 3322
  1. Generate SSH keys using keygen: SSH Keygen is used to generate a key pair which consists of public and private keys to improve the security of SSH connections.
ssh-keygen -t rsa
  1. Copying SSH keys to servers: For SSH authentication, ssh-copy-id command will be used to copy public key(id_rsa.pub) to server.
ssh-copy-id hostname_or_IP
  1. Copy a File Remotely over SSH: SCP tool is used to securely copy files over the SSH protocol.
scp fileName user@remotehost:destinationPath

Example:
scp test.txt test@10.0.0.64:/home/john/Desktop
  1. Edit SSH Config File SSH server options customized by editing the settings in sshd_config file.
sudo vim /etc/ssh/sshd_config
  1. Run commands on a remote server SSH commands can be executed on remote machine using the local machine.
ssh test.remoteserver.com mkdir NewDirectoryName // Creating directory on remote machine
  1. Restart SSH service: You need to restart the service in Linux after making changes to SSH configuration.
sudo ssh service restart
(or)
sudo sshd service restart

Comments