SSH Secure Shell is a cryptographic network protocol for operating network services securely over an unsecured network.

Typical application includes remote command-line, login and remote command execution but any network services can be secured with SSH.

SSH provides a secure channel over an unsecured network in a client-server architecture, connecting an SSH client application with an SSH server.

The protocol distinguishes between two major versions, referred to as SSH-1 and SSH-2.

The standard TCP port for SSH is 22.

Used to access a Unix-like operating system.

SSH designed as a replacement for Telenet and for unsecured remote shell protocols such as the Berkeley rlogin,rsh and rexec protocols.

The encryption used by SSH is intended to provide confidentiality and integrity of data over an unsecured network such as the Internet, although files can be leaked indicate that the NSA can sometimes decrypt SSH, allowing them to read the content of SSH sessions.

SSH uses public-key cryptographic to authenticate the remote computer and allow the user if necessary.

When you first connect to the remote computer you will be located in HOME directory

Basic command

 cd .. will move up one directory

cd <directory_name> will move into specified directory

cd /home/directory /path

cd ~ will return to Home directory

To check the current directory’s contents

  ls command will list all the files and folders in the current directory.

  ls -l will list the content of the directory along with additional information such as size, permissions, and date.

 Ls-a will list all the content including hidden files and folder

Copy files from your location to the remote computer

To copy files from your local computer to the computer you are accessing remotely

 scp  /localdirectory/example1.txt <username> @<remote>: <path>

Will copy file named example1.txt to the specified <path> on the remote computer

scp <username>@<remote>:/home/example1.txt ./ will move example1.txt from the home directory on the remote computer to the current directory on the local computer.

cp example1.txt example2.txt –will create a copy of example1.txt called example2.txt in the same location

cp example1.txt <directory>/ will create a copy of example1.txt In the location specified by <directory>

mv example1.txt example2.txt will rename example1.txt to example2.txt. The file will stay in the same location.

mv directory1 directory2 will rename directory1 to directory2. The directory’s contents will remain unchanged.

mv example1.txt directory1/ will move example1.txt into directory1.

mv example1.txt directory1/example2.txt will move example1.txt into directory1 and rename it to example2.txt

Delete files and directories. If you need to remove anything from the computer you are connected to, you can use the rm command:

rm example1.txt will delete the file example1.txt.

rm –I example1.txt will delete the file example1.txt after prompting you to confirm.

rm directory1/ will delete directory1 and all of its contents.

  • chmod -u+w example1.txt will add the write (modify) permission to the file for the user (u). You can also use the g modifier for group permissions or for world permissions.
  • chmod – g+r example1.txt will add the read (access) permission to the file for the group.
  • There is a large list of permissions that you can use to secure or open various aspects of your system.[3]
  • mkdir -new directory will create a new subdirectory called new directory.
  • pwd -will display your current directory location.
  • who- shows who is logged into the system.
  • pico newfile.txt or vi newfile.txt will create a new file and open the file editor. Different system will have different file editors installed. The most common are pico and vi. You may need to use different commands if you have a different file editor installed.

Creating Encrypted Keys

Allows you to connect to the remote location without having to enter your password each time.

Create the key folder by entering the command $mkdir .ssh

Create  the public and private keys by using the command $ ssh-keygen -t rsa

This will create keys in the .ssh directory id_rsa and id_rsa.pub

Change your private key’s permissions. In order to ensure that the private key is only readable by you, enter the command $ chmod 600 .ssh/id_rsa

$ scp .ssh/id_rsa.pub <username>@<remote>:

Make sure to include the colon (:) at the end of the command.

You will be asked to input your password before the file transfer starts.

 touch- this command is used to create a new file with a chosen extension.

For example, touch NewFile.txt will create a new txt file named “NameFile” in your current directory

Cat-command is used to display the content of the file.

Other commands

Cat info.txt info2.txt >mergedinfo.txt will merge two files together to a file “mergedinfo.txt”.

Pwd- shows you the current location in the file system.

 cp -f source dest-Force the copy procedure by removing the destination files if needed.

cp  -I source dest-will give warning message before overwriting file

cp -u source dest – Update option. Will only copy if the source file is newer than the destination file.

cp -n source dest – Won’t copy if the file already exists (Does not overwrite).

cp -a source dest – This option will archive the files.

du- is used to find the size of a file. Use du -h /filepath to find the space occupied by a file.

wgetis-used to download files from the internet. For example, to fetch a file from the internet and store it in your current directory. use command:
wget
http://fileurl/filename.ext

rep – This command looks for a given string in files/folders. For example, the grep ‘word’ file would search for the phrase ‘word’ in a file named “file”. grep will return the whole line from the file if the phrase is found.

For example, there is a line ‘All in all it’s just another word in a sentence’ in the file named “file”, using command grep ‘word’ file, this line will be outputted to the screen since the word is found.

clear-as the name suggests

tar command is used to create or extract tar.gz

  1. To create a tar.gz archive of a folder, use the command:
    tar cvzf ArchiveName.tar.gz /path/to/directory
  2. To unpack these files, use the command:
    tar xvzf FileName.tar.gz

  3. Here are what the options for the two commands represent:
    • x tells tar to extract files
    • c tells tar to create an archive
    • v stands for ‘verbose’ i.e. tar will print out all the file names in the console
    • z instructs tar to uncompress the archive
    • f tells tar that you are supplying the file name of the archive