Friday, October 22, 2021

Linux:Kubectl : Add New User: Add User to secondary group : Change default Shell of a user

https://linuxize.com/post/how-to-create-users-in-linux-using-the-useradd-command/ 

sudo useradd -m username

ls -la /home/username/

https://careerkarma.com/blog/linux-add-user-to-group/

sudo usermod -a -G group_to_add username


https://www.tecmint.com/change-a-users-default-shell-in-linux/

 usermod --shell /bin/bash tecmint



admin@MACHINEVM01:~$ hostname -I

10.102.25.95 172.17.0.1 172.19.0.1

admin@MACHINEVM01:~$ getent passwd|grep admin

admin:*:16777219:16777220:Kaw, Karan:/home/admin:/bin/bash

admin@MACHINEVM01:~$ getent group|grep docker

docker:x:118:

admin@MACHINEVM01:~$ groups admin

admin : domain users BUILTIN\users

admin@MACHINEVM01:~$ sudo useradd -m eks

[sudo] password for admin:

admin@MACHINEVM01:~$ groups eks

eks : eks

admin@MACHINEVM01:~$ id eks

uid=1006(eks) gid=1006(eks) groups=1006(eks)

admin@MACHINEVM01:~$ getent group|grep eks

eks:x:1006:

admin@MACHINEVM01:~$ getent passwd|grep eks

eks:x:1006:1006::/home/eks:/bin/sh

admin@MACHINEVM01:~$ sudo usermod -a -G docker eks

admin@MACHINEVM01:~$ getent passwd|grep eks

eks:x:1006:1006::/home/eks:/bin/sh

admin@MACHINEVM01:~$ groups eks

eks : eks docker

admin@MACHINEVM01:~$


Docker-Compose Comands


apt install docker.io

apt install docker-compose


docker-compose up

docker-compose up -d


docker image ls

docker container ls


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

docker ps

docker images

docker-compose -f docker-compose.yml down

docker-compose -f docker-compose.yml up -d


 netstat -tulpn|grep LISTEN

 

 tail -f nohup.out



 

Thursday, October 21, 2021

Linux : Bash-Completion :Kubernetes

kubernetes.io/docs/tasks/tools/included/optional-kubectl-configs-bash-linux/


apt-get install bash-completion or yum install bash-completion


o find out, reload your shell and run type _init_completion. If the command succeeds, you're already set, otherwise add the following to your ~/.bashrc file:

source /usr/share/bash-completion/bash_completion


The kubectl completion script for Bash can be generated with the command 

kubectl completion bash


 kubectl rollout history deployment vea-cc  -n fda



Tuesday, October 19, 2021

Linux: SSH:Password for Few Users

https://serverfault.com/questions/285800/how-to-disable-ssh-login-with-password-for-some-users


/etc/ssh/sshd_config
Match User <username>
PasswordAuthentication yes
Match all

EC2: TAG : Shutdown

Instance Schedule

09:00 - 21:00 Mon - Sun

AWS : Userdata after every restart

aws.amazon.com/premiumsupport/knowledge-center/execute-user-data-ec2/
https://serverfault.com/questions/797482/how-to-make-ec2-user-data-script-run-again-on-startup


Content-Type: multipart/mixed; boundary="//"
MIME-Version: 1.0

--//
Content-Type: text/cloud-config; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="cloud-config.txt"

#cloud-config
cloud_final_modules:
- [scripts-user, always]

--//
Content-Type: text/x-shellscript; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="userdata.txt"

#!/bin/bash
/bin/echo "Hello World" >> /tmp/testfile.txt
--//--

Monday, October 18, 2021

AWS : Userdata - Bash Script Fired Once

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-user-account-cloud-init-user-data/

docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#retrieving-the-public-key

github.com/Cloud-Yeti/aws-ec2-course/blob/master/labs/lab07-ec2-userdata-ssh-with-password.MD


aws.amazon.com/blogs/aws/troubleshoot-boot-and-networking-issues-with-new-ec2-serial-console/

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html

#!/bin/bash
sed 's/PasswordAuthentication no/PasswordAuthentication yes/' -i /etc/ssh/sshd_config
systemctl restart sshd
service sshd restart


#TODO: replace bob with your desired username
useradd bob
# TODO: replace password123 with desired password and change bob to your username chosen in useradd 
echo "password123" | passwd --stdin bob

------------------------------------------------------------------------------
!/bin/bash
sed 's/PasswordAuthentication no/PasswordAuthentication yes/' -i /etc/ssh/sshd_config
service sshd restart
echo "admin@123" | passwd --stdin root



Azure - Pipeline - Add Approver for Stage

https://learn.microsoft.com/en-us/azure/devops/pipelines/process/approvals?view=azure-devops&tabs=check-pass