Friday, July 21, 2023

Linux Keybased Authentication

 Two types of authentications


1) Username and Password

2) Key based authentication


Username & Password: Create new user and set password, Which very common method


2) Key based authentication: Create user generate public/private key


Fresh user :-


Generate public/private key

Public key save on server and private key for user which user want access remote.


When you generate key then default one directory create under user home direcotry .ssh/


id_rsa {Private Key}

id_rsa.pub {Public Key}



publickey store under /home/user/.ssh/authorized_keys 

When you copy authorized key then check file permission if not then provide though below command


chown username /home/user/.ssh/authorized_keys (file ownership will change)


Now user will access remote by key.



Requirement exiting user remote access via username & password now we have provide only key based authentication


Generate public and private key.


#ssh-keygen (Generate public and private key under /home/user/.ssh/


id_rsa (private key)

id_rsa.pub (public key)


#ssh-copy-id username@ip address (This cmd for copy public key in user home directory and create file like Authorized_keys)


Enter 

Asking the user password (AWS Linux ec2 there password authoentication is disable so we have enabled from vim /etc/ssh/sshd_config then search PasswordAuthentication by default its no sow we have replace yes then save file and restart ssh service.

#systemctl restart sshd


Then agin use below 


ssh-copy-id username@ip address


You can see message below message after enter password of user.


Number of key(s) added: 1


Now try logging into the machine, with:   "ssh 'ravikant@172.31.83.133'"

and check to make sure that only the key(s) you wanted were added.


now lets see user is accessble remote

Wednesday, July 12, 2023

Windows Operating System Important configuration for IT Guys

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

IPV6 disabled from registry settings

-----------------------------------------------------------------------------------------------------------------------------

reg add hklm\system\currentcontrolset\services\tcpip6\parameters /v DisabledComponents /t REG_DWORD /d 0xFF /f

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

Windows Firewall rules by command line.

-----------------------------------------------------------------------------------------------------------------------------

netsh advfirewall set allprofiles state off

netsh advfirewall show all

netsh advfirewall set allprofiles state on   (Firewall on)

netsh advfirewall firewall add rule name="RDP-3001" dir=in action=allow protocol=TCP localport=3001

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

Windows RDP Enable, Disable  and Port change

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

To disable RDP :- 

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 1

To Enable RDP :- 

Set-ItemProperty -Path 'HKLM:\System\CurrentControlSet\Control\Terminal Server' -name "fDenyTSConnections" -value 0

RDP Port Change :- 

Reg.exe add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d "3001" /f


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

Firewall

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

netsh advfirewall set allprofiles state off

netsh advfirewall show all

netsh advfirewall set allprofiles state on   (Firewall on)