Skip to main content

CREATING AND SIGN INTO LINUX/CENTOS SERVER USING SSH KEY


If "user_name" is a user in server "example.com" and you want to setup ssh key to this server and also able to login to this server using ssh key only.
Follow these command in the command line.

1) cd /home/user_name (user_name is the name of the user)

2) mkdir -p .ssh

3) chmod 0700 .ssh/

4) ssh-keygen -t rsa

Result printed will be something like below:

Result:
Generating public/private rsa key pair.                                        
Enter file in which to save the key (/home/user_name/.ssh/id_rsa):            
Enter passphrase (empty for no passphrase):                                    
Enter same passphrase again:                                                  
Your identification has been saved in /home/user_name/.ssh/id_rsa.            
Your public key has been saved in /home/user_name/.ssh/id_rsa.pub.            
The key fingerprint is:                                                        
5d:0f:b5:8e:d9:a4:4b:d0:1c:3f:b6:35:1d:44:89:27 user_name@example.com            

5) You can enter any key name as your wish. If you skip this, by default it will be given "id_rsa".
You can also give a passphrase to your key to make more secure. You can also skip this.

Your public key will be "id_rsa.pub(or you_entered_name.pub)" in .ssh folder. Private key will be "id_rsa(or you_entered_name)" in the same folder.

6) Check "authorized_keys" file exist in .ssh folder. If not type this command "touch .ssh/authorized_keys". Typing this command even though authorized_keys will not delete the data in authorized_keys file.

7) scp .ssh/id_rsa.pub user_name@example.com:~/.ssh/authorized_keys

Result printed will be something like below:

The authenticity of host 'example.com (127.0.0.1)' can't be established.         
RSA key fingerprint is 5d:0f:b5:8e:d9:a4:4b:d0:1c:3f:b6:35:1d:44:89:27.          
Are you sure you want to continue connecting (yes/no)? yes                       
Warning: Permanently added 'example.com' (RSA) to the list of known hosts.       
user_name@example.com's password:                                                
id_rsa.pub                                                                                                                            100%  421     0.4KB/s        00:00                                                                           

8) chmod 0600 .ssh/authorized_keys

Private ssh key is deploid in your server for this user. Please download "id_rsa" file from .ssh folder.

9) Later make .ppk file from this "id_rsa" file from "putty gen" software. .ppk file generated will be private key for your server login.

10) In the command line,

nano /etc/ssh/

11) Open sshd_config file from this folder using any of editor. I prefer vi editor.

vi sshd_config

12) In this file , set "PasswordAuthentication" to "no"

13) Finally restart the ssh.

/etc/init.d/sshd restart to restart ssh

14) Now you can login to your server using ssh key without entering your previous password.

Popular posts from this blog

Implementing Client Side WebRTC using Sipml5 javascript

Step 1:

Download and require Sipml5 library function.

Step 2:

Initialize sipml5 Engine in your web page :

var readyCallback = function(e) {
// function called when sipml is successfully initialised.
createSipStack(); // calling this function to create sip stack(see below)
};

var errorCallback = function(e) {
// function called when error occured during sipml initialisation.
};

SIPml.init(readyCallback, errorCallback);

Step 3:

Create Sip Stack :-
Sip Stack is an object that must be created before making/receiving call and sms. Creating Sip stack is an asynchronous process, so you need to create an event listener function to get state change notification.

var sipStack;

function EventListener(e) {

/*
* e.type ;type of event listener
* e.session ; current event session
* e.getSipResponseCode() ; event response code
* e.description ; event description
*/

if(e.type == 'started'){
// successfully started the stack.
register();
} else if(e.type == 'i_new_call'){
// when new incoming call comes.
      …

Setup Asterisk 13 with FreePBX 13 in CentOS 7

Launch CentOS 7 AWS Ec2 InstanceLog in to your aws consoleGo to ec2 management page and click Launch Instance on Instance pageIn Choose AMI step, go to AWS MarketPlace tab and search CentOS 7 on search field. List of centos 7 ami's will be available.Select CentOS 7 (x86_64) ami which is free tier eligible. Select your instance type and click configure instance. Keep default values from Configure Instance to Add Tags stepsIn configure security group, create a security group which allow minimum ports openSSH : port 22HTTP : port 80Custom UDP Rule : 10000-20000 (if you are giving RTP ports 10000-20000)Custom UDP Rule : 5060 (ChanSIP port)Custom TCP Rule : 5060 (ChanSIP Port)Click Launch Instance. Select your key file and accept terms to launch instance.
Setup CentOS Server SSH into newly created CentOS server with username centos and your key file.Update all existing packagessudo yum update -yNow start http service(you can access your server via browser by going to your server ip addres…

MULTIPLE FILE UPLOAD USING AJAX WITH PROGRESS BAR

Uploading multiple files using ajax makes a pleasant feeling to the user. It makes even more happier if upload progress status is printed with percentage.

            In this blog, you will make a file upload form using ajax with file upload progress bar.

Prerequisites :

1) Javascript supported browser
2) LAMP Server / XAMPP Server

Code :

index.html

<!DOCTYPE html>
<html> <head><title>Multiple File Upload using Ajax</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="//code.jquery.com/jquery-1.10.2.min.js"></script> </head> <body><div><form action="action.php" method="post" enctype="multipart/form-data" id="multiple-upload-form"><input type="button" id="select-file-btn" value="Select Files" onclick="document.getElementById('files').click(); return false;&qu…