Limitless

"I never am really satisfied that I understand anything; because, understand it well as I may, my comprehension can only be an infinitesimal fraction of all I want to understand about the many connections and relations which occur to me, how the matter in question was first thought of or arrived at, etc., etc.".
(Ada Lovelace)

LinuxBanner

SSH

SSH ("Secure Shell") is a protocol for securely accessing one computer from another.
Despite the name, SSH allows you to run command line and graphical programs, transfer files, and even create secure virtual private networks over the Internet. To use SSH, you will need to install an SSH client on the computer you connect from, and an SSH server on the computer you connect to. The most popular Linux SSH client and Linux SSH server are maintained by the OpenSSH project.
All modern Unix-like systems (Linux, BSDs, and others) include a command-line ssh client. To login to your computer from a Unix-like machine, go to a command-line and type:



ssh username@IP_address #FOR EXAMPLE ssh [email protected] #Specifying the port if the server is listening on a different one (from the standard 22) ssh -P 220 [email protected]

From Windows I would like to suggest to use the popular graphical SSH client, PuTTY. You can download the Windows client from here

putty

SCP

SCP allows files to be copied to, from, or between different hosts. It uses ssh for data transfer and provides the same authentication and same level of security as ssh. As every Unix command, for all flags, the best way is to check the manual page.


man scp



SCP: From "Remote" to "Local"


scp username@IP_address:FILENAME_TO_GET.txt /some/local/directory #We will copy from a server with IP 192.168.0.15 all files .txt from the server folder /home/shady/p1 #to the client folder /home/Dennis/stuff scp [email protected]:/home/shady/p1/*.txt /home/Dennis/stuff #Specifying the port scp -P220 [email protected]:/home/shady/p1/*.txt /home/Dennis/stuff #rsync instead of SCP, in order to watch the progress and recover in case of fail transfer. rsync -avz -e 'ssh -p 1716' --progress [email protected]:/home/shady/p1/* /home/Dennis/stuff



SCP: From "Local" to "Remote"


scp Local_file_To_Transfer username@Server_IP:/some/remote/directory #We are going to copy from Local pc to a remote Server #a file called Debian_8_x64.iso scp Debian_8_x64.iso [email protected]:/home/Dennis/ISO #Specifying the port scp -P 1716 Debian_8_x64.iso [email protected]:/home/Dennis/ISO #With Rsync rsync -avz /localPATH/ [email protected]:/home/Dennis/ISO #In order to see the progree of copy add the flag --progress #and if we need to use a different port (instead of the standard 22) rsync -avz -e 'ssh -p 1716' --progress Debian_8_x64.iso [email protected]:/home/Dennis/ISO



SCP: From "Remote" to "Remote"


scp your_username@SERVER1:/some/remote/directory/fileToTransfer.txt \ your_username@SERVER2:/some/remote/directory/



SFTP: Bi-directional, with Filezilla-Client

FileZilla Client is a fast and reliable cross-platform FTP, FTPS and SFTP client with lots of useful features and an intuitive graphical user interface.
SFTP means SSH File Transfer Protocol. So we can use our SSH credential in order to connect to the server using this protocol. You can download the sources and the binary files here.
Otherwise you can download and install it from the official repository:


#Debian / Ubuntu distros apt-get install filezilla #RedHat, Centos distros yum -y install filezilla

filezillaClientfilezillaClient

Now Let's do our first SSH connection using our personal account


############# # ADA USERS # ############# ############## # ALAN USERS # ##############



A simple script that copy a file from local to remote

Copy and paste this script into your pc and set chmod +x


#if you will call this file # remtolocal.sh chmod 744 remtolocal.sh




#!/bin/bash #this is just a check to avoid to use the ROOT user if [ "$EUID" -eq 0 ] then echo "Do NOT RUN THIS SCRIPT AS ROOT!" exit fi clear read -p "Insert your username " user read -p "insert the IP of the server " ip echo " " echo -e "\e[0mWELCOME \e[31m$user \e[0m you are going to copy from [REMOTE to LOCAL]\e[0m" read -p "what file you'd like to copy on your pc? ( *.txt to copy all .txt files ) " filename echo -e "\e[0mYou've selected the file \e[32m$filename\e[0m" read -p "insert the destination of the file ( write . for current directory ) " dest echo -e "\e[0mThe file \e[31m$filename\e[0m will be copied on your local drive to the path \e[32m$dest\e[0m" rsync -avz -e 'ssh -p 22' --progress $user@$ip:/home/$user/$filename $dest