How to create ssh key

This method can be used on any linux server.
for this tutorial, i will be using AWS server.

how to create SSH-KEYGEN
======================
1) #ssh-keygen -f <username>
*Enter passphrase (empty for no passphrase): //empty
*Enter same passphrase again: //empty
*will create <username>.pem <username>.pub
2) copy key --> /tmp - use winscp to receive and transfer key(depends on your preferences) to other server
3) execute user.sh
#sh user.sh

groupadd admingroup
%admingroup ALL=(ALL) NOPASSWD:ALL
admingroup:x:1007:username


how to use the .pem key on your targer server. (enable the .pem key)
=================================================

1) chmod 0600 <username>.pem
2) ssh-keygen -y
   Enter file in which the key is (/root/.ssh/id_rsa): /tmp/<username>.pem
3) save this in <username>.pub

reference source

#+++++++++
#user.sh +
#+++++++++

#!/bin/bash/

echo "Insert new username: "
read USER

useradd $USER -m
cd /home/$USER
mkdir /home/$USER/.ssh
chmod 700 /home/$USER/.ssh
chown $USER:$USER /home/$USER/.ssh
#check the location of user.pub
cat /tmp/key/$USER.pub >> /home/$USER/.ssh/authorized_keys
chmod 600 /home/$USER/.ssh/authorized_keys
chown $USER:$USER /home/$USER/.ssh/authorized_keys

#end user.sh


+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
change at sudoer (but we already group at admingroup eg: #nano /etc/group)

username ALL=(ALL) NOPASSWD:ALL

=========================================

How to user .ppk in Putty
Insert the hostname or IP address of target server. 

Go to Connection > SSH > Auth > Browse
Choose your newly generated .ppk
Click on Open


now you can access using your server using putty without using password. only need to use your apk.

if you have any suggestion or question, please write in the comment section below.

Comments