DEV Community

Cover image for Connect Server Using Terminal & SSH
Akilesh
Akilesh

Posted on • Updated on

Connect Server Using Terminal & SSH

'' This article is published using Lamento🍋

Using terminal we are going to establish a remote connection to a Remote Server like (Droplet, E2C or any cloud vm).

If you are using Linux or Mac you are good to go but in windows you should download git-bash.

1) Now to generate your SSH key type his commends in your terminal.

It's better to generate SSH keys inside .ssh folder


ssh-keygen

Enter fullscreen mode Exit fullscreen mode

2) Now name your key

you can name your key what ever suits for you

3) Don't need any passphrase

Image description

We have generated two files public key & private key

  • public key - Used by the Server

  • private key - Used by the Client

Image description

4) Open the public key files


cat ur-key-name.pub

Enter fullscreen mode Exit fullscreen mode

Image description

We need to provide our public key to the remote server by opening it in terminal and copy the phrase.

Image description

5) To establish connection between client with server


ssh -i ./droplet-ssh-key root@157.245.104.56

Enter fullscreen mode Exit fullscreen mode

Abbreviation: ssh -i keyfile target_machineusername@host

What's the meaning of -i in ssh?

By providing the private keyfile and our server username and ip address we are opening a connection between client and server

Image description

If you see the above message we have successfully connected our client with the server

Bonus

You can check your system specification with this commends


free -h


df -h


lscpu

Enter fullscreen mode Exit fullscreen mode

To terminate the session enter exit in terminal.

Top comments (0)