CyberKeeda In Social Media
Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

How to enable password based ssh authentication in ec2 instance

 



EC2 Linux SSH Authentication.

By default, preferred and default way of accessing any ec2 linux instance is key based authentication.
Here in this blog post, we will know 
  • How to enable basic authentication that is password based authentication in ec2 instance.
  • How to enable root login to ec2 instance.
I will keep on updating the post as per my learnings and used in practical scenarios.

Let's go through it :)

How to enable root login on linux ec2 instance.
  • Login to ec2 linux instance using it's private key.
  • Sudo to root
  • change password for root
  • Permit root login in sshd_config file

Syntax

[ec2-user@ip-10-0-1-116 ~]$ sudo su

Change root password from below command.


[root@ip-10-0-1-116 ec2-user]# passwd root

Permit root login by un-commenting the below line in sshd_config


[root@ip-10-0-1-116 ec2-user]# vi /etc/ssh/sshd_config

From


# PermitRootLogin yes

To

PermitRootLogin yes


How to enable password based authentication for ssh user.
  • Login to ec2 linux instance using it's private key.
  • Sudo to root
  • Permit root login in sshd_config file
  • Restart sshd service

Syntax

[ec2-user@ip-10-0-1-116 ~]$ sudo su

Permit root login by un-commenting the below line in sshd_config


[root@ip-10-0-1-116 ec2-user]# vi /etc/ssh/sshd_config

From


# PasswordAuthentication yes

To

PasswordAuthentication yes

Restart SSHD service

service sshd restart


Login and check !
Read more ...

TcpDump Cheat Sheet

 

TCP Dump Cheat Sheet

When we talk about Client-Server, there is network involved and when we talk about network, every one is quite familiar with tcpdump and Wireshark.
Network knows Packets and tcpdump is a CLI tool that knows packet very well.

tcpdump is a very useful took with a lot of functions, hence filters and parameters plays a very important role to segregate what exactly we need, without going much in MAN pages,  within this blog post, we will cover mostly used tcpdump commands and their usage.


Usage 1

Capture packets from any interface and write it's output in pcap format file named as pcktdump.pack 

Syntax Template

# tcpdump -i any -w /tmp/pcktdump.pcap host 10.10.100.75

More details

  • -i any
    • i - interface
    • -i any - any interface
  • -w /tmp/pckdump.pcap
    • -w - write
    • -w /tmp/pcktdump.pcap : Write to file /tmp/pcktdump.pcap
  • host 10.10.100.75
    • Packet filter with incoming request on IP 10.10.100.75



Usage 2

Capture packets from any interface and save multiple files of fixed size.


Syntax Template

# tcpdump -i any -W 3 -C 10 -w /tmp/pcktdump.pcap host 10.10.10.75

More details

  • -i any
    • i - interface
    • -i any - any interface
  • -W 3 -C 10
    • Rotating buffer of 3 files (-W 3) and tcpdump switches to another file once the current file reaches 10,000,000 bytes ( 10Mb)
  • -w /tmp/pckdump.pcap
    • -w - write
    • -w /tmp/pcktdump.pacp: Write to file /tmp/pcktdump.pcap
  • host 10.10.100.75
    • Packet filter with incoming request on IP 10.10.10.75


Read more ...

How to disable Visual mode in VIM

Have you witnessed, suddenly your copy paste stopped working from windows box to putty terminal into VIM insert console,  more over to it, there is a strange string named as VISUAL at the bottom of the screen.

Visual mode is a feature of VIM which changes the interaction with vim when there is a mouse selection. This made copy+pasting annoying, let know it's cure here.

Open terminal and create a hidden file under your home directory as "vimrc"

# touch ~/.vimrc

# echo "set mouse-=a" >> ~/.vimrc

And yes you are done, back to usual mode no Visual :) 


Info from : GitHub


Read more ...

S3cmd - A faster way for AWS S3 Operations.


S3cmd


A very faster and reliable CLI tool for AWS object storage (S3) operations.


So this tutorial is just a walk through to
  • How to install s3cmd
  • How to configure S3cmd
  • Basic operations copy, move, list.

Requirements.
  • AWS Console access.
  • API Token for same account.
  • PIP is installed within Windows system to install python packages

Installation.

For Windows
pip install s3cmd
For Linux
sudo apt-get install s3cmd -y


Configuration.

Before we proceed to run cli commands, let configure s3cmd configuration file to authenticate.

For Linux -
Toggle to home directory of your account.

# cd ~
Create an empty hidden file named as .s3cfg

# touch .s3cfg
Add the below lines and add your own access_key and secret_key and save.

[default]

# Login credentials
access_key = AKMYOWNACCESSKEYHDEG
secret_key = 1DwMYownAccessSecretKeyoOV8

Now we are ready to do s3 operations using s3cmd cli, all cli commands are same for windows and linux operating systems.


Object Storage operations.

  • List content of your S3 Bucket.
# s3cmd ls s3://<Your AWS Bucket Name/
  • Create an new Bucket
# s3cmd mb s3://my_own_s3_newbucket/
  • Uploading content within a Bucket.
# s3cmd put myfile1.txt myimage.jpg s3://my_own_s3_newbucket/
    • Download content from Bucket.
    # s3cmd get s3://my_own_s3_newbucket/myimage.jpg myimage.jpg
    • Remove and existing Bucket
    # s3cmd rb s3://my_own_s3_newbucket/
      • Move content of one bucket(Source) to another(Destination).
      # s3cmd mv --recursive s3://failed/ s3://old_failed/



      Read more ...

      Ubuntu : How to access Android device media files through USB


      How to  access Media files from Android device, whether it's internal phone storage or external microSD card.

      Steps to access Android Devices in Ubuntu, Linux Mint.

      Here MTP stands for Media Transfer Protocol, which comes to existese when we connect our Smartphone through USB cable into computer/laptops.

      Just Install libmtp, FUSE file system for MTP enabled devices mtpfs using below commands.

      # sudo apt-get install go-mtpfs
      sudo apt-get install libmtp
      sudo apt-get install mtpfs mtp-tools
      mtp-detect 
      mtp-detect  ==> Run this command to verify your Android Device.

      • Rejack your Android device using USB cable in Ubuntu.
      • In your Android device, swipe down from above in the home screen and click Touch for more options. 
      • In the next menu, select option “Transfer File (MTP)“.
      • If required then, restart your device manager to
        sudo service udev restart

      And you are done :) 




      Read more ...

      SSH from your favourite browser using Shellinabox




      Shellinabox is perfect tool if you have any of the requirement.

      Missing Putty or SSH agent on your desktop  ?
      Looking for Client less agent to SSH ?
      Want to SSH your Linux server or desktop from mobile.

      So lets move ahead and just follow the steps to install Shellinabox.

      Video tutorial, for video lovers.


      ShellinaBox Installation on  CentOS7

      Introduction [ Shell In A Box ]

      Shell In A Box implements a web server that can export arbitrary command line tools to a web based terminal emulator. This emulator is accessible to any JavaScript and CSS enabled web browser and does not require any additional browser plugins.

      Official repository link

      More info on official git page :  https://github.com/shellinabox/shellinabox

      Installation.

      Intsall EPEL Repo.


      [root@cyberkeeda ~]# yum install epel-release 


      Install shellinabox package


      [root@cyberkeeda ~]# yum install shellinabox


      Configuration.

      Shellinabox configuration file  :    /etc/sysconfig/shellinaboxd


       Lets have a look on the file and allow and modify the important lines

      [root@cyberkeeda ~]# vim /etc/sysconfig/shellinaboxd



      # Shell in a box daemon configuration
      # For details see shellinaboxd man page

      # Basic options
      USER=shellinabox
      GROUP=shellinabox
      CERTDIR=/var/lib/shellinabox
      PORT=4200
      OPTS="--disable-ssl-menu -s /:LOGIN"
      OPTS="-t -s /:SSH:192.168.0.181"

      PORT

      PORT=4200

      Chnage PORT to some other to avoid conflict between sytem level ports 

      I will be changing it to 6162 

      SSH HOST

      OPTS="-t -s /:SSH:192.168.0.101"

      Chnage IP or Hostname to your default login host, by default shellinabox will ask to login into it, then later you can ssh and jump into n number of servers.


      My final config file would look as

      # Shell in a box daemon configuration
      # For details see shellinaboxd man page

      # Basic options
      USER=shellinabox
      GROUP=shellinabox
      CERTDIR=/var/lib/shellinabox
      PORT=6162
      OPTS="--disable-ssl-menu -s /:LOGIN"
      OPTS="-t -s /:SSH:192.168.0.101"


      Configuration Done..

      Important : 

      STOP Firewalld iptables and disable selinux 

      #    Service firewalld stop
      #    Service iptables stop

      Disable SELINUX : change status of selinux to disabled

      Finally Restart the shellinaboxd daemon.



      [root@cyberkeeda ~]# service shellinaboxd start

      Read more ...
      Designed By Jackuna