How to use ssh

on Linux (and MacOS)

Maybe the most important tool you might need to use everyday as engineer/developper, the Secure Shell (ssh). It became a mandatory tool for each web developper as well as embedded or software development in general. Let's ask Wikipedia:

Secure Shell (SSH) is a cryptographic network protocol for operating network services securely over an unsecured network. The best known example application is for remote login to computer systems by users.

SSH provides a secure channel over an unsecured network in a client-server architecture, connecting an SSH client application with an SSH server. Common applications include remote command-line login and remote command execution, but any network service can be secured with SSH. The protocol specification distinguishes between two major versions, referred to as SSH-1 and SSH-2.

The most visible application of the protocol is for access to shell accounts on Unix-like operating systems, but it sees some limited use on Windows as well.

Simply, with ssh you can connect from a point A to a point B with several options for strong authentification and it protect the communication and entigrity with strong encryption. I can say without doubt, it is the best solution to avoid non-protected login like telnet, FTP and rlogin. I am sure a lot of web developer ask themself: "Oh god ! I'm using FTP everyday, Alexandre who can I secure my file exchange between my server and my desktop??!!". There the answer --> use SSH (or a repository).

How does the SSH protocol work ?

  1. the client initiate the connection with the server 
  2. the server sends his public key
  3. negiciation between client and server to open a secure channel
  4. the client login to server operating system

What is the difference between ssh and sshd ?

Nice look ! If you already try to work with ssh, you should see ssh and sshd (mean ssh daemon).

ssh: is used when you want to create a ssh session.

sshd: is used when you want to receive ssh sessions.

How to configure ssh ?

It depend on your platform, of course Windows didn't have a native ssh solution (#Windobe), but MacOS and Linux have it !

Ssh is using file to be configured, each time you restart your ssh or sshd, they will read these files, apply the configuration and start.

 

How to use ssh ?

Remotly copying files --> scp command who using ssh

Remote session through tenimal:

ssh <username>@<ip address>

<username> is the username who you will use on the remote platform.

<ip address> can be a domaine name as well.

example:

ssh alexandre@127.0.0.1

-p port Force ssh to use this port
-i identity_file Ssh will use this file for the public key authentification (see step 2.)
-c cipher Ssh will use the cipher speficied by the user to encrypt his data
-1 Select SSH version 1 protocol (obsolete ... stop using it !)
-2 Select SSH version 2 protocol
-4 Force scp to use IPv4 addresses
-6 Force scp to use IPv6 addresses

 

Wrote by Raspaud Alexandre at May 29 2018, contact alexandre.raspaud@gmail.com.