Monday, August 22, 2022

Rightfax error code 0x80070021

 how to fix can't access RightFax web error 500.19

Go to Start windows -> Server Manager-> Install HTTP Activation



Reference: http error 500.19 and error code: 0x80070021




Wednesday, June 29, 2022

how to access samba file share from windows server 2019

 Ref: www.alibabacloud.com

gpedit.msc

After edit not restart Server

Solution

  1. On an on-premises Windows client, press Win+R to open the Run dialog box. In the Run dialog box, enter gpedit.msc in the Open field, and then click OK.

  2. In the left-side navigation pane of the Local Group Policy Editor dialog box, choose Computer Configuration > Administrative templates > Network > Lanman Workstation.

  3. In the Setting section of the Lanman Workstation page, click Enable insecure guest logons.

  4. In the Enable insecure guest logons dialog box, select Enabled. Click Apply.

  5. Mount the SMB share.

  6. If you still fail to mount the SMB share, restart the Windows client to clean up the cache and try again.

Edit share configure on Samba

Change follow the Red highlight 
-------------------------------------------//
[Downloads]
   comment = Triple X
   path = /home/user/Downloads
   guest ok = yes
   read only = no
   writeable = yes
   browseable = yes
   create mask = 0775
   directory mask = 0775
   valid users = user, nobody
//--------------------------------------------

Allow user nobody only Write on folder Software

$ history | grep nobody
id nobody
chown +g nobody Downloads/Software/
chown nobody -R Downloads/Software/
sudo chown nobody -R Downloads/Software/

Wednesday, June 8, 2022

ssh error connect to Linux server (Ubuntu 20.04, 22.04) Unable to negotiate with xxx

I found this error "Unable to negotiate with IPADDRESS port XXXX: no matching key exchange method found. Their offer: diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1" when I use ssh command to remote Linux Server on Ubuntu client version 20.04 up. This error can fix by creating a new file config at the path .ssh see below.

cd /home/userlogin/.ssh

vim  config

Add text following

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

Host mail.yourserver.com diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

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

save file and run command ssh again it is successful with ubuntu 20.04 but if you use ubuntu 22.04 you'll find more errors like this "Unable to negotiate with IPADDRESS port XXXX: no matching host key type found. Their offer: ssh-rsa,ssh-dss" you can fix it by adding more text at file config like this.

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

Host mail.yourserver.com diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,diffie-hellman-group1-sha1

        HostKeyAlgorithms ssh-rsa

        PubkeyAcceptedKeyTypes ssh-rsa

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

now you can use ssh command on ubuntu and you can create a shortcut command in file .bashrc like this

add text following to the button

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

# alias

alias myserver='ssh -oKexAlgorithms=+diffie-hellman-group1-sha1 -p xxxx admin@mail.yourserver.com'

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

and then run . ~/.bashrc for creating shortcut command

Referrence:

https://sysadmin.psu.ac.th

https://www.openssh.com

For  HostKeyAlgorithms ssh-rsa

https://www.linuxquestions.org

Monday, October 18, 2021

Test telnet smpt office 365 port 587 with Powershell

Rum powershell command with

$creds = get-credential

Enter username & Password Email

copy and paste with this command

Send-MailMessage –From test@tv.com –To akka@global.net –Subject "Fwd: Test Email" –Body "Test SMTP Service from Powershell on Port 587" -SmtpServer smtp.office365.com -Credential $creds -UseSsl -Port 587

with attach file

Send-MailMessage –From test@tv.com –To akka@global.net –Subject "Fwd: Test Email" –Body "Test SMTP Service from Powershell on Port 587" -Attachments "C:\PS\SampleAttachment.txt" -SmtpServer smtp.office365.com -Credential $creds -UseSsl -Port 587

Ref. uncaoffice-365-test-smtp-on-port-587

https://infra.engineer/azure/56-office-365-test-smtp-on-port-587-using-powershell


Thursday, October 7, 2021

mount NTFS with dual boot windows 10 and ubuntu 20.04 (R/W)

 1. run this command on Windows 10 with Administrator (If not run this ubuntu will not R/W file on mount drive)

powercfg /h off

Ref: ntfs-3g

2. Add command on file /etc/fstab 

# mount NTFS drive

UUID=483C6CC03C6CAB20 /media/user/drive_c ntfs-3g defaults,uid=1000,gid=1000,rw 0 1

UUID=3874B76D74B72D0E /media/user/drive_d ntfs-3g defaults,uid=1000,gid=1000,rw 0 1

* Create folder for mount Path file

mkdir -p /media/user/drive_c

mkdir -p /media/user/drive_d

* For check disk NTFS on ubuntu run command

sudo blkid

* Allow user to RW file

uid=1000,gid=1000,rw

 

Sunday, August 22, 2021

howto mont file NTFS in windows to Ubuntu 20.04.3 LTS

 I use multi OS in my notebook. I want to mount file NTFS from windows to Ubuntu.

1. Create file

sudo mkdir -p /media/user/drive_c

sudo mkdir -p /media/user/drive_d

sudo chown user:guser /media/user/* -R

2. check path location NTFS

sudo fdisk -l

Device              Start        End   Sectors   Size Type

/dev/nvme0n1p1       2048     206847    204800   100M EFI System

/dev/nvme0n1p2     206848     239615     32768    16M Microsoft reserved

/dev/nvme0n1p3     239616  168011775 167772160    80G Microsoft basic data

/dev/nvme0n1p4  168011776  285198335 117186560  55.9G Linux filesystem

/dev/nvme0n1p5  762908672  967706623 204797952  97.7G Microsoft basic data

/dev/nvme0n1p6  967708672  968757247   1048576   512M Windows recovery environme

/dev/nvme0n1p7  968757248  998117375  29360128    14G Windows recovery environme

/dev/nvme0n1p8  998117376 1000214527   2097152     1G Windows recovery environme

/dev/nvme0n1p9  285198336  300822527  15624192   7.5G Linux swap

/dev/nvme0n1p10 300822528  762908671 462086144 220.3G Linux filesystem

Partition table entries are not in disk order.

3. add command to file /etc/fstab
# mount NTFS drive
/dev/nvme0n1p3 /media/user/drive_c ntfs defaults,uid=1000,gid=1000,rw 0 0
/dev/nvme0n1p5 /media/user/drive_d ntfs defaults,uid=1000,gid=1000,rw 0 0

4. run command
sudo mount -a
or restart notebook.


Tuesday, December 29, 2020

Script check quemail stuck on server and alert mail to mailadmin for resolve

vim checkquemail.sh

---------------------------------Start---------------------------------------------

#!/bin/bash

#Start check quemail on system

PATHCHECK="/home/user/quemail.txt"

/usr/sbin/postqueue -p |tail -n 1 > $PATHCHECK && /usr/sbin/postqueue -p |grep "^[A-F0-9]" |sort -k5rn -k6n >> $PATHCHECK

#If found quemail stuck on systems and then send mail alert to Systemadmin

#Set the variable which equal to zero

prev_count=0

count=$(grep 'MAILER' $PATHCHECK | wc -l)

#check word 'MAILER' on text file on path $PATHCHECK if more than 0 do next step

if [ "$prev_count" -lt "$count" ] ; then

# Send a mail to given email id when errors found in log

#SUBJECT="WARNING: found $count quemail was stuck on mailgw, pls check now "`date --date='yesterday' '+%b %e'`""

SUBJECT="WARNING: found $count quemail was stuck on mailgw, pls check now."

#This is a temp file, which is created to store the email message.

MESSAGE="/tmp/logs.txt"

FROM="noreply@domain.com"

TO="mailadmin@domain.com"

echo "ATTENTION: found that there are $count mail queues in the system left to be sent for urgent inspection." >> $MESSAGE

echo "Server: `hostname`" >> $MESSAGE

echo "\n" >> $MESSAGE

echo "+------------------------------------------------------------------------------------+" >> $MESSAGE

echo "$count mail queues" >> $MESSAGE

echo "+------------------------------------------------------------------------------------+" >> $MESSAGE

grep -i "`date --date='yesterday' '+%b %e'`" $PATHCHECK | grep 'MAILER' $PATHCHECK >>  $MESSAGE

#list quemail stuck on system

mutt -s "$SUBJECT" -e "my_hdr From: Server Info <noreply@domain.com>" -- "$TO" < $MESSAGE

rm $MESSAGE

fi

---------------------------End Script----------------------------------

Create crontab for run script

---------crontab -e --------

# m h  dom mon dow   command

*/30 * * * * /home/user/./checkquemail.sh

#check every 30 minute

--------


Ref: https://www.2daygeek.com/linux-bash-script-to-monitor-messages-log-warning-error-critical-send-email/


Wednesday, December 2, 2020

Delete old file over 7 day

----------------script--------------------------------------

find /pathfile/* -type f -mtime +7 -exec rm -rf {} \;

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

Tuesday, June 16, 2020

find and delete file on server linux

how to find and delete file on server linux

#find /data/001/ -name -delete

Ref:
inux-unix-how-to-find-and-remove-files


1. Find Files Using Name in Current Directory

# find . -name tecmint.txt

./tecmint.txt








Wednesday, June 10, 2020

How to install Linux AD controller samba4 on Debian 10


fix problem windows xp not create User Profile on AD server because SAMBA V.4 up not support smbv1 them support smbv2 up

add this to /etc/samba/smb.conf
---------------
[global]
.
.
ntlm auth = ntlmv1-permitted
---------------

systemctl restart samba-ad-dc
systemctl status samba-ad-dc

Add AD user with Profile

samba-tool user add user01 --profile-path=\\\IP\Profiles\\user01

Or change by Active Directory on windows


GPO command
Execute command
gpupdate /force

display execute
gpresult /r


How to setup additional failover replication AD with debian 10.03

1. setup IP and host name
vim /etc/network/interfaces
iface ens192 inet static
address 172.16.x.78/24
gateway 172.16.x.1
# dns-* options are implemented by the resolvconf package, if installed
dns-nameservers 172.16.x.77 172.16.x.67 172.16.x.68
dns-search ad.domain.com

vim /etc/hosts
127.0.0.1 localhost
172.16.x.77 dc1.ad.domain.com dc1
172.16.x.78 dc2.ad.domai.com dc2

vim /etc/resolv.conf 
search ad.domain.com
nameserver 172.16.x.77
nameserver 172.16.x.67
nameserver 172.16.x.68

Reboot system

ping dc1.ad.domain.com
ping dc2.ad.domain.com

2. install package
apt install samba attr dnsutils net-tools smbclient krb5-user krb5-config winbind libpam-winbind libnss-winbind libpam-krb5

Disable lecacy samba daemons
systemctl stop smbd nmbd winbind
systemctl disable smbd nmbd winbind

Move or delete to default smb.conf file
mv /etc/samba/smb.conf /etc/samba/smb.conf.org

Configure kerberos to use the existing Active Directory. Copy the krb5.conf from Primary domain
scp root@ad.domain.com:/etc/krb5.conf /etc

And get a kerberos ticket for the Active Directory.
kinit administrator
Warning: Your password will expire in 40 days on Mon 01 Feb 2021 02:29:25 PM +07
klist 
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: administrator@AD.DOMAIN.COM

2. run samba-tool command to join the realm using an account with administrative privileges on your domain
#samba-tool domain join ad.domain.com DC -U"administrator"
Finding a writeable DC for domain 'ad.domain.com'
Found DC dc1.ad.domain.com
Password for [WORKGROUP\adminstrator]:

3. Adding configure samba file
vim /etc/samba/smb.conf

       dns forwarder = 172.16.x.67 (IP DNS)
       idmap_ldb:use rfc2307 = yes
.
.
        template shell = /bin/bash
    winbind use default domain = true
    winbind offline logon = false
    winbind nss info = rfc2307
        winbind enum users = yes
        winbind enum groups = yes

4. Enable samba service
        systemctl restart samba-ad-dc.service 
        systemctl status samba-ad-dc.service
        systemctl enable samba-ad-dc.service

5. Check replication. Warning: No NC replicated for Connection! can be ignored
#samba-tool drs showrepl
Warning: No NC replicated for Connection!

6. create link krb5.conf
        mv /etc/krb5.conf /etc/krb5.conf.initial
        ln -s /var/lib/samba/private/krb5.conf /etc/
Test kerberos
# kinit administrator
Password for administrator@AD.DOMAIN.COM:
Warning: Your password will expire in 40 days on Mon 01 Feb 2021 02:29:25 PM +07
# klist 
Ticket cache: FILE:/tmp/krb5cc_0
Default principal: administrator@AD.DOMAIN.COM

7. finish test create user AD dc2.ad.domain.com
root@dc2:~# samba-tool user add 5712016

8. Check user at dc1.ad.domain.com
root@dc1:~# samba-tool user list
Unknown parameter encountered: "profile acls"
Ignoring unknown parameter "profile acls"
uservista
5712016

9. fix join domain debian to debian fail
root@proxy01:~# realm join -U administrator@dc1.ad.domain.com AD.DOMAIN.COM --verbose
 * Resolving: _ldap._tcp.ad.domain.com
 * Resolving: ad.domain.com
 * Performing LDAP DSE lookup on: 172.16.9.77
 * Successfully discovered: ad.domain.com
Password for administrator@ad.domain.com: 
 * Unconditionally checking packages
 * Resolving required packages
 ! PackageKit not available: The name org.freedesktop.PackageKit was not provided by any .service files
 ! Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli
realm: Couldn't join realm: Necessary packages are not installed: sssd-tools sssd libnss-sss libpam-sss adcli

msktutil --auto-update --verbose -k /etc/squid/proxy.keytab --computer-name proxy01

fix with install package packagekit
apt install packagekit


Ref.

BASIC USER MANAGEMENT
# sudo su

Display domain users list
 root@smb:~# samba-tool user list

Add a domain user
 root@smb:~# samba-tool user create ubuntu

Delete a domain user
 root@smb:~# samba-tool user delete ubuntu

Reset password for a user
 root@smb:~# samba-tool user setpassword ubuntu

Set expiry for a user
 root@smb:~# samba-tool user setexpiry ubuntu --days=7

Disable/Enable user account
 root@smb:~# samba-tool user disable ubuntu

Display domain groups list
 root@smb:~# samba-tool group list

Display members in a group
 root@smb:~# samba-tool group listmembers "Domain Users"

Add a domain group
 root@smb:~# samba-tool group add ServerWorld

Delete a domain group
 root@smb:~# samba-tool group delete ServerWorld

Add a member from a domain group.
 root@smb:~# samba-tool group addmembers ServerWorld ubuntu

Remove members to group ServerWorld
 root@smb:~# samba-tool group removemembers ServerWorld ubuntu

Change Domain User Password
# sudo smbpasswd -a username
 [sudo] password for admin: 
 New SMB password:
 Retype new SMB password:

Ref:
1. Samba-4-Active-Directory-Domain-Controller-on-Ubuntu-18-04-Server
2. install-samba-4-7-6-ad-dc-ubuntu-18-04-bind-9-11-dns-backend-ad-rfc2307
3. Profile
4. Install AD Controller to windows
5. Restrict website
6. manage-samba4-active-directory-linux-command-line/