Linux - Local and Remote Logins (SSH)

History of Linux Development:

  • Started in MIT as part of project MULTICS (Multiplexed Information and Computing Service)

  • Dennis Ritchie then wrote the complete OS in C language and named it as UNICS which finally ended up being UNIX

  • Linus Torvalds in 1991 developed a free OS based on UNIX and wanted to call it as FREAX (Free OS) but his friends insisted him to have his name and the product ended being called as LINUX

Local Console Command Line Access

Command Line : Is basically a text based interface which user provides input to the computer system or operating system

  • Shell is a means by which we can communicate with Unix/Linux OS. There are many types of shells like bash, tshell etc

  • Linux command line is provided by shell and in RHEL default shell is called as bash (GNU Bourne-Again shell)

  • If you are windows user for understanding you can think shell as similar to command line and if you are Mac user then the terminal you use is basically a shell

  • We can automate tasks using scripts in bash shell

  • Shell commands basically has three main parts:

  1. command: This is the name of the program which we are supposed to run

  2. Options: Various different options based on the command selected

  3. Arguments: command entered in #1 may expect parameters to be passed on which are called as arguments, these may be mandatory or optional too

  • If you are doubtful of what options or arguments to be passed then you could use help feature to explore more on this command --help or can use ‘man’ command to know more about any command
man nameOfCommand #Ex: man ls will provide details about ls command
  • '#' character appears at the end of the shell prompt to signify that you are using a privileged account and '$' for the normal user account

  • To quit and end the shell session, you can use exit or Ctrl+D

SSH

  • SSH (Secure Shell) is a protocol which facilitates secure communications between two systems using a client-server architecture and allows users to log in to server host systems remotely

  • Authentication between two systems happens via key exchange without password i.e through private-public key scheme

  • Private Key generated is confidential and should be saved or protected at all times

  • Public Key generated is open for all and copied to the host server for which user intends to connect

  • SSH Server is the one which validates whether the private key presented is valid one for the public key present there by establishing connection only if it is a valid one

  • To generate ssh-keys we use command ssh-keygen which results in private key 'id_rsa' and public key `id_rsa.pub' being generated in default directory '~/.ssh'

  • During generation of private key we can provide passphrase which works as password for the private key but it defeats the purpose of password-less access to hosts/servers but to over come this we can execute below commands

ssh-agent 
ssh-add # To add the private key at beginning of the session
#To specify private key if there are more than one and when you need to be more specific
ssh-add -i ~/.ssh/other/id_rsa
  • File Permissions of the private key should be 600 and public key should be 644 (We will learn more about file permissions in this series later)

  • So once the private key-public key combination is generated then in order to access any hosts/servers the public key has to be copied to the destination system, we could do it manually or use below commands

ssh-copy-id # This helps to copy the public key from ~/.ssh/id_rsa.pub 

[deepak@testSystem~]$ ssh-copy-id root@testuser.kaliyona.com
  • Some important ssh files/directories to be aware of
FileComment
/etc/ssh/ssh_configThe default SSH client configuration file. Note that it is overridden by ~/.ssh/config if it exists.
~/.ssh/authorized_keysHolds a list of authorized public keys for servers. When the client connects to a server, the server authenticates the client by checking its signed public key stored within this file.
~/.ssh/known_hostsContains host keys of SSH servers accessed by the user. This file is very important for ensuring that the SSH client is connecting to the correct SSH server.

For more details, please check RedHat Documentation