Find & Locate | SSH (Secure Shell)

Find & Locate | SSH (Secure Shell)

Linux Workshop (Day4)

Hey, all!! I'm Rudrakshi back here with my new blog in which I'll be covering concepts and terminologies covered in the 4th session of #Linuxworkshop conducted by Pranav Jambare sir.

This blog presents information about Find and Locate command used in the Linux system and details about SSH.

Locate & Find

Find:

  • Find is a command used to search for a file and directory.

  • However, these files & directories can be searched on the basis of name, modification time, permission, and size.

  • It can also find files or directories owned by a particular owner or group or by location.

  • It can also be used to find files in the current directory or in a different directory.

  • Basically, the find command is a very useful tool for finding files and directories on Linux systems.

  • Find searches for your file recursively from a starting point that you specify

  • Is more powerful and flexible, but slower and more resource intensive.

  • Syntax:

      find [path] -[options]
    
  • Different options:

    • "-name pattern": searches file on the basis of the name given.

    • "-type": searches file or directory on the basis of its given type.

    • "-user username": searches file on the basis of user name.

    • "-group groupname": searches file on the basis of the name of the group**.**

    • "-perm mode": searches files based on their permission.

    • "-exec command {} \;": executes a command on each matching file or directory.

    • "-inum": searches files based on their inode value.

    • "-size": searches on the basis of size provided.

Locate:

  • Locate command is used to find files and directives quickly.

  • Locate relies on a database that is maintained by an "updatedb" command.

  • Locate searches a prebuilt database of files on your system, which makes it faster than the find command.

  • the database allows locate command to find files or directories quickly without making it search the entire database.

  • It is important to update database for acquiring latest changes and find files.

  • Syntax:

locate [options] patter

SSH

  • SSH (Secure Shell) is a network protocol that allows users to connect safely and securely over an unsecured network.

  • SSH is a protocol for remote communication in Linux.

  • SSH is a widely used and supported protocol.

  • SSH provides encryption for protecting data and authentication for user verification.

  • For using SSH you need to install SSH-client on a local computer and SSH-server on a remote computer.

  • Syntax:

      ssh username@IPaddress
    
  • where username is the user name on a remote computer and "IP address" is the hostname of a remote computer.

SSH is used for secure file transfer, displaying graphics through remote systems, port sharing, and many more things.

SSH uses two types of keys:

Private Key:

  • A private key is used to authenticate a user for a remote system.

  • It is used to verify a user's identity.

  • It is kept private by the user it is recommended to not share it with anyone for your system's security.

  • Private keys are used to secure SSH connections.

Public Key:

  • A public key is a cryptographic key used for the authentication of users to the remote system.

  • A public key is mainly stored on a remote system in a file called "authorized_key" which is located in the user's home directory.

  • The public key is copied to the remote system and added to the "authorized_key" file while the private key is kept on the user's local system.

  • Using public key authentication is more secure than a password, as there is no need to transmit a password over a network.

Assembling SSH connection:

  • For the creation of SSH connection systems need to have these two important packages installed.

    1. openssh-client

    2. openssh-server

  • The Syntax for Installing Packages:

      $ yum install [packagename]
      # $ yum install openssh-server
      # $ yum install openssh-client
    
  • The syntax for checking port 22:

      $ netstat -tunlp|grep 22
    
  • The syntax for checking the status of service:

      $ systemctl status [serviceName]
      #e.g.systemctl status sshd
    
  • The syntax for starting the service:

      $ systemctl start [serviceName]
    
  • The syntax for stopping the service:

      $ systemctl stop [serviceName]
    
  • The syntax for restarting the service:

      $ systemctl restart [serviceName]
    
  • The syntax for connecting servers remotely:

      $ ssh username@hostid
      # ssh rsawant@132.167.122.1
    
  • The Syntax for allowing/denying users to connect with a specific server:

      #use the following command to visit configuration file
      $ vim /etc/ss/sshd_config
      #then add
      $ AllowUser [username] or $ DenyUser [username]
      #after adding save and restart the service and then check the status