Add a private float variable _shakeDecay in camera script and declare a public function shake. Call this function when shake has to be activated.

 public void Shake()  
      {  
           _shakeDecay = 0f;  
           StopCoroutine("CameraShake");  
           StartCoroutine("CameraShake");  
      }  
      IEnumerator CameraShake()  
      {  
           while (_shakeDecay < 2f)  
           {  
                _shakeDecay += Time.deltaTime;  
                transform.position = transform.position + new Vector3(Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f), Random.Range(-0.2f, 0.2f));  
                 yield return null;  
           }  
           yield return null;  
      }