• Skip to primary navigation
  • Skip to content

GitopsCentral

  • Home
  • Courses
  • Roadmap
  • About
  • Log In
  • Sign Up

How to generate ssh keys and grant access to a remote server

May 31, 2019 by shaik zillani

i1.wp.com

In this blog post, I will show you how to generate ssh keys on local and grant access to your server.

Step-1: Create SSH keys on your local

First, you need to create ssh keys on your system by using ssh-keygen

ssh-keygen

This will ask you to enter passphrase for extra security, for now we can skip this by just hitting enter. After that it will create keys (one private key and one public key) in the directory, ~/.ssh/id_rsa and ~/.ssh/id_rsa.pub with the following output as shown below.

id_rsa.pub is your public key which needs to be shared to your remote server

The key's randomart image is:
+---[RSA 2048]----+
| ..o+            |
|..o. .           |
|oo.   +          |
|+.   + .o  .     |
|o     ooSo. .    |
| .    oo.+o  .   |
|  o   o*..=.+.oo.|
| +    ..+o.+o*+o.|
|.E.    . .+oo+=o.|
+----[SHA256]-----+

Please note that even if you are on windows the procedure is same, but the keys are generated in different directory, you check this blog for more clarity.

Step-2: Upload Public key to remote server

Now as we have the public key generated from ssh-keygen, we need to upload the keys to the remote server inside the file, ~/.ssh/authorized_keys.

To do this, you can use the command below, make sure that update username and remote_host in the command below,

cat ~/.ssh/id_rsa.pub | ssh username@remote_host "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys"

Finally, this will give you access to the remote server right away! and you can verify if you are able to login via ssh using command below,

ssh username@remote_host

Please also checkout our other blog posts on gitopscentral.in

ssh linux,  ssh

© Copyright 2016-2025 gitopscentral · All Rights Reserved ·