2023年12月17日 星期日

Linux password

Source

* How to Setup Strong Password Policy on Ubuntu Linux
* DISABLE LINUX PAM MODULE FOR SPECIFIC USERS !


How to Setup Strong Password Policy on Ubuntu Linux

This brief tutorial shows students and new users how to set up a firm password policy on Ubuntu 18.04 | 16.04.

Out of the box, Ubuntu machines are not set up with an advanced password policy. Any password, including weak ones, can be used and never expire. This may not be secure in some environments.

To configure a more secure password policy and protect your users from hackers and intrusions, you need to take some steps, and this post shows you how to do that.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

When you’re ready to set up a firm password policy on Ubuntu, follow the steps below:

Ensure Passwords Expire

In most business environments, user passwords are configured to expire every 60 to 90 days. Desktop users are not configured like business environments so that a single password can be used forever.

If you want to configure Ubuntu to force users to change passwords regularly, you can run the commands below to open the login. defs file.

sudo nano /etc/login.defs

For example, if you want the account password to be changed every 60 days and several days before it changes again, edit the highlighted lines in the file.

You can also set the number of days a warning is given before a password expires.

# Password aging controls:
#
#       PASS_MAX_DAYS   Maximum number of days a password may be used.
#       PASS_MIN_DAYS   Minimum number of days allowed between password changes.
#       PASS_WARN_AGE   Number of days warning given before a password expires.
#
PASS_MAX_DAYS   60
PASS_MIN_DAYS   1
PASS_WARN_AGE   7
.

Save the file and exit.

Configure PAM Password Module

A PAM module called pam_pwquality can be included with Ubuntu to require strong passwords for system users. pam_pwquality performs several basic checks, just like the old pam_cracklib module, including not allowing passwords to include a username from the GECOS field, rejecting passwords with more than N number of characters, and many other password-related checks.

To install and use the pam_pwquality module, run the commands below:

sudo apt install libpam-pwquality cracklib-runtime

pam_pwquality main configuration file is at /etc/pam.d/common-password. Run the commands below to edit the file.

sudo nano /etc/pam.d/common-password

A reasonable password requirement will follow similar guidelines.

  • Allow N number of retries before returning error [retry=3]
  • Set a minimal password length [minlen=8]
  • Set N number of repeated characters [maxrepeat =3]
  • Password must have uppercase characters [ucredit = -1]
  • Password must have lowercase characters [dcredit=-1]
  • Reject password with account name found in GECOS [gecoscheck=1]

Edit the highlighted line and add some of the requirements above to enforce.

# here are the per-package modules (the "Primary" block)
password        requisite                       pam_pwquality.so retry=3 minlen=8 maxrepeat=3 ucredit=-1 lcredit=-1 dcredit=-1 ocredit=-1 difok=3 gecoscheck=1 reject_username enforce_for_root

password        [success=1 default=ignore]      pam_unix.so obscure use_authtok try_first_pass sha512
# here's the fallback if no module succeeds
password        requisite                       pam_deny.so

Make the above changes that fit your environment. When done, reboot your machine, and the changes above should apply.

That’s it!

Conclusion:

This post showed you how to set up a firm password policy on Ubuntu 18.04 | 16.04. If you find errors in the above, please use the form below to report.


DISABLE LINUX PAM MODULE FOR SPECIFIC USERS !

For user case where you want to skip MultiFactorAuthentication / PAM module like google authentication validation code for specific users and keep it enabled for the rest, below solution can be used-
1) Create a user group on the Linux instance. We are going to disable MFA/PAM for users present in this new group-
sudo groupadd <groupname>
2) Create User or add existing user to newly created group-
sudo useradd <username>
sudo usermod -a -G <groupname> <username>

3) Edit /etc/pam.d/sshd file and add the below statement to skip PAM module for the newly created group-

auth [success=done default=ignore] pam_succeed_if.so user ingroup <groupname>

Optional-

If full access is required for this new group then add below line to visudo file-

%<groupname>ALL=(ALL)       NOPASSWD: ALL

When a user will be created and added to the new group, on first login MFA will be created but will not be enforced on further logins.

eMMC

 linux - Check health of eMMC - Super User

Linux pipe

Q: How to process input pipe in real time?
A: Linux pipe is buffered (4096? 65536? bytes)
     Solution#1:
Unix buffering delays output to stdout, ruins your day | TurnKey GNU/Linux (turnkeylinux.org)
fflush(stdout);
     Solution#2:

2023年12月13日 星期三

英文標點符號

英文標點符號大全 | Wall Street English


’Apostrophe撇號
() Bracket (英式) / Parentheses (美式)括號
 : Colon冒號
 , Comma逗號
 - Dash破折號
 … Ellipsis省略號
 ! Exclamation Mark (英式) / Point (美式)感嘆號
 . Full Stop (英式) / Period (美式)句號
 《 》 Guillemets書名號
 – Hyphen連字號
?  Question Mark問號
 "" Quotation Mark引號
;  Semicolon分號
/ Slash斜線


[英文] 標點符號翻譯 Punctuation Marks @ 搗蛋鬼 扭扭 :: 痞客邦 :: (pixnet.net)

.

點

dot

 

-

破折號/中線

dash

。

句號

period

/

斜線

virgule ; slash

,

逗號

comma

\

反斜線

backslash

:

冒號

colon

~

波浪號

tilde (or swung dash)

;

分號

semicolon

...

省略號

ellipsis

!

驚嘆號

exclamation

( )

圓括號

parentheses

@

小老鼠

at

'  '

單引號

single quotation marks

?

問號

question mark

“ ”

雙引號

double quotation marks

'

所有格號

apostrophe

《》

法文引號或書名號

French quotes

*

星號 /米字 

asterisk (or star)

[ ]

方括號

(square) brackets

§

分節號

section ; division

{ }

大括號

braces

→

箭號

arrow

‖

雙線號

parallel

2023年12月10日 星期日

Linux coredump

int main(void)
{
    char *ptr = NULL;
    *ptr = 'A'; // This will cause a segmentation fault 
    return 0;
}

root@A9x28:/# ulimit -a | grep core
-c: core file size (blocks)        unlimited

root@A9x28:/# sysctl -a
fs.suid_dumpable = 2
kernel.core_pattern = /data/core

root@A9x28:/# cat /proc/sys/kernel/core_pattern
/data/core

root@A9x28:/# ./create_coredump
Segmentation fault (core dumped)

2023年11月16日 星期四

RFX (RFQ RFP RFI)

RFX

因應客戶開發時期的不同階段及與供應商的不同合作關係(ODM/OEM/EMS), 客戶會對於他所認為夠格(Qualified)的供應商發出RFP/RFI/RFQ等不同產品建議或報價邀請, 對於我所知道的科技相關產品行業而言, 其間的差別及因應事項分享如下:

[RFQ]=Request for Quotation(報價邀請書), 此為最常見的邀請報價形式.通常客戶在此RFQ文件中已經詳細定義了求產品規格, 品質要求,預計應用,驗證方式,出貨包裝,交貨數量及出貨日期等等,然後發出該RFQ給若干供應商. 而身為供應商的我方, 應該依照客戶需求的各要項依序列示我方產品的符合程度, 或提出更 佳建議方案, 並提出最具競爭力的價格方案. 通常回覆時除了報價單外, 另外會有一方完整的我方準備的回覆文件(ppt file)說明我方準備的產品計劃及對於RFQ各項要件的說明.

[RFP/RFI] RFP=Request for Proposal; RFI= Request for Information; 實務上, 對於我所操作及回覆客戶的實際經驗, RFP/RFI兩者之間可以視為同一種客戶邀請....

2023年11月14日 星期二

Handbook - M$ WORD

 Source 比較及合併文件的兩個版本 - Microsoft Support

您可以比較兩種版本的文件,瞭解它們的差異。 您也可以將同一份文件的兩種版本合併成一份新文件。 在這兩種情況中,Word 都會以修訂標記顯示不同之處。

請執行下列其中一項操作︰

比較一份文件的兩種版本

  1. 針對您要比較的兩個文件版本,開啟其中一個版本。

  2. 在 [ 校閱]功能表上,選取[比較檔]。

  3. 在 [ 原始檔案] 清單中,選取原始檔案。

  4. 在 [ 修訂的檔 ] 清單中,流覽至檔的其他版本,然後選取 [確定]。

    修訂複本的變更會合並成以檔原始版本為基礎的新複本。 原始文件將維持不變。 修訂標記會顯示修訂版文件的所有差異。

    提示: 若要變更檔比較設定或顯示的詳細資料層級,請在 [ 工具 ] 功能表上指向 [ 追蹤修訂],按一下 [ 比較檔],然後按一下 [顯示更多選項的向下箭號]。

將一份文件的兩個版本做合併

  1. 針對您要合併的兩個文件版本,開啟其中一個版本。

  2. 在 [ 校閱]功能表上,選取[合併檔]。

  3. 在 原始檔案 清單中,選取檔的一個版本。

  4. 在 [ 修訂的檔 ] 清單中,流覽至檔的其他版本,然後選取 [確定]。

    修訂複本的變更會合並成以檔原始版本為基礎的新複本。 原始文件將維持不變。 修訂標記會顯示修訂版文件的所有差異。