A Beginners Guide To SSH : How to start with SSH

The most common way of connecting to a remote Linux server is through SSH (aka Secure Shell). SSH is a secure protocol used as the primary means of connecting to Linux servers remotely. It provides a text-based interface by spawning a remote shell. After connecting, all commands you type in your local terminal are sent to the remote server and executed there. SSH uses public key cryptography for both connection and authentication. SSH is the default tool for system administrator to perform various tasks on servers remotely. In order to use SSH to access your server remotely, you will need a SSH client on your local machine. For Linux machines ssh-client is comes with built-in, and for windows machine you can use putty : https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html here.



Now lets get start with ssh :
  • Connecting to SSH-Server in Linux Machine
 $ ssh username@[server_name]
At the above syntax the the username is the name of user and server_name is the server hostname.

Example:
 $ ssh ajay@ubuntu
Now if you are connecting to that server first time, then the ssh client will ask if you are sure you want to connect to a new, previously unknown host
 $ ssh ajay@ubuntu
 The authenticity of host 'ubuntu (192.168.0.151)' can't be established.
 ECDSA key fingerprint is e4:b2:2c:32:64:0f:92:11:ca:01:46:60:ea:67:7e:23.
 Are you sure you want to continue connecting (yes/no)? 
Say “yes” and you will be prompted for the root account’s password
 $ ssh ajay@ubuntu
 The authenticity of host 'ubuntu (192.168.0.151)' can't be established.
 ECDSA key fingerprint is e4:b2:2c:32:64:0f:92:11:ca:01:46:60:ea:67:7e:23.
 Are you sure you want to continue connecting (yes/no)? yes
 Warning: Permanently added 'ubuntu' (ECDSA) to the list of known hosts.
 vuln@ubuntu's password:
And after putting the password you will connected to the ssh server, and remember the password are not visible, when you type them.
 $ ssh ajay@ubuntu
 The authenticity of host 'ubuntu (192.168.0.151)' can't be established.
 ECDSA key fingerprint is e4:b2:2c:32:64:0f:92:11:ca:01:46:60:ea:67:7e:23.
 Are you sure you want to continue connecting (yes/no)? yes
 Warning: Permanently added 'ubuntu' (ECDSA) to the list of known hosts.
 ajay@ubuntu's password:

 Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.4.0-96-generic i686)
  * Documentation:  https://help.ubuntu.com
  * Management:     https://landscape.canonical.com
  * Support:        https://ubuntu.com/advantage
 162 packages can be updated.
 56 updates are security updates.

 Last login: Thu Dec 28 06:50:22 2017
 ajay@ubuntu:~$
And to quit the ssh session just type exit and hit enter.

We can also use the below syntax to connect to server
 $ ssh server_name -l useranme
Example :
 $ ssh ubuntu -l ajay
And if the username and hostname is same on the server then use the below syntax
 $ ssh servername
Example :
 $ ssh ubuntu
And to access the root user, the syntax would be
 $ ssh root@ubuntu
or
 $ ssh ubuntu -l root
But, before you continue, it is important to note that logging in to a server as root is a powerful but also potentially DANGEROUS system administration tool. The root user is allowed to change/delete practically everything in a server without any type of warning or confirmation of changes being made.
And in case if you don't know the hostname of server then you can also use the IP address to connect to that server. For example :
 $ ssh ajay@192.168.0.151
or
 $ ssh 192.168.0.151 -l ajay


  • Connecting to SSH-Server in Windows Machine with Putty
I have downloaded portable version of putty https://the.earth.li/~sgtath..../w32/putty.exe

Now run the program and at the Host_Name put the hostname or IP address of your server, the default port is 22 for ssh service, now click open button to start session.


And similarly like above, if you are connecting to that server first time, then the ssh client will ask if you are sure you want to connect to a new, previously unknown host 


Click on YES button and it will ask you for user name and password to log in, now give the user name and password


And you can successfully logged in to your server through putty client.


Conclusion :

So, This is the very basics of How you can start using SSH. For further details about SSH Check out below Posts :

How to Set up SSH keys on a linux based Client/Server
How to reconnect to a disconnected ssh session on Linux based SSH Server
How to install OpenSSH Server on Ubuntu Linux 16.04