Skip to main content

Removing Authorized keys & history from AWS instance

AWS recommends to delete authorized keys and and history from your instances before creating and publishing AMI.

You might get below error when you submit your AMI for scanning without removing the keys.
Authorized keys found
Authorized key(s) found in the following location(s):
  • /home/ec2-user/.ssh/authorized_keys:1
  • /root/.ssh/authorized_keys:1
To find authorized keys :

find / -name "authorized_keys" -print -exec cat {} \;

To remove keys:

find / -name "authorized_keys" –exec rm –f {} \;


To remove history :

find /root/.*history /home/*/.*history -exec rm -f {} \;


For more information refer to https://aws.amazon.com/articles/0155828273219400


Comments

Popular posts from this blog

Testing Restful API with Spock - groovy

Spock is a testing and specification framework for Java and Groovy applications. Here we will use groovy RestClient along with Spock to test Restful Services. import groovyx.net.http.RESTClient import spock.lang.Specification import spock.lang.Shared class MyApiSpec extends Specification { @Shared RESTClient restClient def setupSpec() {                 restClient = new RESTClient('hostnamewithport') restClient.handler.failure  = restClient.handler.success }  def 'test get method'(){  given:  restClient.headers.Accept = 'application/json'  when:  def resp = restClient .get(path: 'path(ex:/api/list/'), query:[param1:'param1value',param2:'param2value'] )  then:  resp.status == 200  resp.data.somejsonobject == 'expectedjson'  }  def 'test post method'(){  given:  restClient .headers.Accept = 'appli...

Java - Windons Authentication to SQL Server with jTDS Driver

To make jTDS driver to work with your SQL server windows authentication use below jdbc url format. 1. windows authentication without SSO jdbc:jtds:sqlserver:// <HOSTNAME>:1433;instance= SQLEXPRESS;databaseName= lportal;domain=<domain>;user= <user>;password=<password> 2. windows authentication with SSO jdbc:jtds:sqlserver:// <HOSTNAME>:1433;instance= SQLEXPRESS;databaseName= lportal;domain=<domain> and set the java argument something like this to load ntlmauth.dll   -Djava.library.path="<driver-folder>/windowsSSO" Note : if you are installing sqlexpress/sql server on your desktop or server you need to enable tcp/ip connectivity to the instance. Steps to enable tcp/ip connectibity: 1. Open SQL Server Configuration Manager 2. Goto  Configuration Manager > SQL Server Network Configuration > Protocols for <instancename> 3. Right click on TCP/IP and select enable. ...