Showing posts with label System - Linux. Show all posts
Showing posts with label System - Linux. Show all posts

PAM rejected by account configuration[7]: Authentication failure

one of the user can’t login to the system, even you have reset the password, account was not locked by observing the shadow file.
[root@stpdb log]# grep abc /etc/shadow
abc:$1$.6KFA6pB$Z7AgIDAF3nvMh0LX.lTPh.:16870:0:99999:14:7::

[root@stpdb log]# chage -l abc
Minimum:        0
Maximum:        99999
Warning:        14
Inactive:       7
Last Change:            Mar 10, 2016
Password Expires:       Never
Password Inactive:      Never
Account Expires:        Never

Then you found this
[root@stpdb pam.d]# grep -i pam_tally /var/log/messages
Mar 10 17:46:33 stpdb pam_tally[4865]: user afiza (786) tally 20, deny 5
..

[root@stpdb pam.d]# grep -i abc /var/log/secure
Mar 10 17:40:15 stpdb sshd[4648]: Failed password for abc from 172.20.42.249 port 3034 ssh2
Mar 10 17:40:15 stpdb sshd[4648]: Failed none for abc from 172.20.42.249 port 3034 ssh2
Mar 10 17:40:15 stpdb sshd[4648]: Failed keyboard-interactive for abc from 172.20.42.249 port 3034 ssh2
..

[root@stpdb log]# faillog
Username   Failures  Maximum  Latest
root             64        0  Thu Apr 24 20:26:06 +0800 2014 on 172.30.5.10
abc             20        0  Thu Mar 10 19:16:15 +0800 2016 on 172.30.4.38

[root@stpdb pam.d]# grep pam_tally /etc/pam.d/system-auth
auth        required      /lib/security/pam_tally.so no_magic_root
account     required      /lib/security/pam_tally.so deny=5 reset no_magic_root

This case, the user has been locked because of the “deny 5” setting, as you can check from the “faillog” command. To reset the user failure count, use below:
[root@stpdb log]# pam_tally --user=afiza –reset
[root@stpdb log]# faillog
Username   Failures  Maximum  Latest
root             64        0  Thu Apr 24 20:26:06 +0800 2014 on 172.30.5.10
abc             0        0  Thu Mar 10 19:16:15 +0800 2016 on 172.30.4.38


small and capital files under /etc/rc0.d/ /etc/rc1.d/ /etc/rc2.d/ /etc/rc3.d/

This is the so-called "System V" or "SysV" boot method.

K means "this program is going to be KILLED" the numbers give the order; first 01 then 02 then the next and so on.

S means "this program is going to be STARTED" and it starts the 01 then 02 and so on.

_ALL_ of these symlinks get their turn in that runlevel (rc3.d = runlevel 3)

Note: 
only CAPITALS get their turn; small letters (s and k as opposed to S and K) don't do anything.

Add RAW devices for Oracle DB ASM disk for Redhat Enterprise Linux 5 (RHEL5)

Make sure you check on the recommended disk type (block or raw devices for the version of Oracle DB)

Determine the LUN / disks dedicated for RAW devices.
In example below, I already know that my disks for RAW devices is 10 x 32GB each, hence below should be my needed disks.
[root@abc ~]# fdisk -l | grep 34
Disk /dev/xvdd doesn't contain a valid partition table
Disk /dev/xvde doesn't contain a valid partition table
Disk /dev/xvdf doesn't contain a valid partition table
Disk /dev/xvdg doesn't contain a valid partition table
Disk /dev/xvdh doesn't contain a valid partition table
Disk /dev/xvdi doesn't contain a valid partition table
Disk /dev/xvdj doesn't contain a valid partition table
Disk /dev/xvdk doesn't contain a valid partition table
Disk /dev/xvdl doesn't contain a valid partition table
Disk /dev/xvdm doesn't contain a valid partition table
Disk /dev/dm-0 doesn't contain a valid partition table
Disk /dev/dm-1 doesn't contain a valid partition table
Disk /dev/dm-2 doesn't contain a valid partition table
Disk /dev/dm-3 doesn't contain a valid partition table
Disk /dev/dm-4 doesn't contain a valid partition table
Disk /dev/dm-5 doesn't contain a valid partition table
/dev/xvda2              33       19581   157027342+  8e  Linux LVM
Disk /dev/xvdd: 34.3 GB, 34359738368 bytes
Disk /dev/xvde: 34.3 GB, 34359738368 bytes
Disk /dev/xvdf: 34.3 GB, 34359738368 bytes
Disk /dev/xvdg: 34.3 GB, 34359738368 bytes
Disk /dev/xvdh: 34.3 GB, 34359738368 bytes
Disk /dev/xvdi: 34.3 GB, 34359738368 bytes
Disk /dev/xvdj: 34.3 GB, 34359738368 bytes
Disk /dev/xvdk: 34.3 GB, 34359738368 bytes
Disk /dev/xvdl: 34.3 GB, 34359738368 bytes
Disk /dev/xvdm: 34.3 GB, 34359738368 bytes

Now you will need to initialize those disks, command below will wipe out the whole disks, make sure you do it on the right disks
dd if=/dev/zero of=/dev/xvdd count=1
dd if=/dev/zero of=/dev/xvde count=1
dd if=/dev/zero of=/dev/xvdf count=1
dd if=/dev/zero of=/dev/xvdg count=1
dd if=/dev/zero of=/dev/xvdh count=1
dd if=/dev/zero of=/dev/xvdi count=1
dd if=/dev/zero of=/dev/xvdj count=1
dd if=/dev/zero of=/dev/xvdk count=1
dd if=/dev/zero of=/dev/xvdl count=1
dd if=/dev/zero of=/dev/xvdm count=1

Now add them to the /etc/sysconfig/rawdevices to bind them persistently
/dev/raw/raw1 /dev/xvdd
/dev/raw/raw2 /dev/xvde
/dev/raw/raw3 /dev/xvdf
/dev/raw/raw4 /dev/xvdg
/dev/raw/raw5 /dev/xvdh
/dev/raw/raw6 /dev/xvdi
/dev/raw/raw7 /dev/xvdj
/dev/raw/raw8 /dev/xvdk
/dev/raw/raw9 /dev/xvdl
/dev/raw/raw10 /dev/xvdm

Start the “rawdevices” service to read and execute all entries defined above
/etc/init.d/rawdevices start

Make sure it was started upon reboot.
chkconfig rawdevices on

Set the user permission for Oracle DB user to read and write to these raw devices in “/etc/udev/rules.d/60-raw.rules”
ACTION=="add", KERNEL=="raw*", OWNER="oragrid", GROUP="asmadmin", MODE="0660"

Test the permission using “udev_test” command
[root@abc ~]# udevtest /class/raw/raw1
main: looking at device '/devices/virtual/raw/raw1' from subsystem 'raw'
udev_rules_get_name: rule applied, 'raw1' becomes 'raw/raw1'
udev_device_event: device '/devices/virtual/raw/raw1' already in database, validate currently present symlinks
udev_node_add: creating device node '/dev/raw/raw1', major = '162', minor = '1', mode = '0660', uid = '501', gid = '504'
main: run: 'socket:/org/kernel/udev/monitor'
main: run: '/lib/udev/udev_run_devd'
main: run: 'socket:/org/freedesktop/hal/udev_event'
main: run: '/sbin/pam_console_apply /dev/raw/raw1 '

Activate the udev rules to set permission
[root@abc dev]# ll /dev/raw
total 0
crw------- 1 root root 162,  1 May 13 10:08 raw1
crw------- 1 root root 162, 10 May 13 10:08 raw10
crw------- 1 root root 162,  2 May 13 10:08 raw2
crw------- 1 root root 162,  3 May 13 10:08 raw3
crw------- 1 root root 162,  4 May 13 10:08 raw4
crw------- 1 root root 162,  5 May 13 10:08 raw5
crw------- 1 root root 162,  6 May 13 10:08 raw6
crw------- 1 root root 162,  7 May 13 10:08 raw7
crw------- 1 root root 162,  8 May 13 10:08 raw8
crw------- 1 root root 162,  9 May 13 10:08 raw9

[root@abc dev]# start_udev
Starting udev:                                             [  OK  ]

[root@abc dev]# ll /dev/raw
total 0
crw-rw---- 1 oragrid asmadmin 162,  1 May 13 10:08 raw1
crw-rw---- 1 oragrid asmadmin 162, 10 May 13 10:08 raw10
crw-rw---- 1 oragrid asmadmin 162,  2 May 13 10:08 raw2
crw-rw---- 1 oragrid asmadmin 162,  3 May 13 10:08 raw3
crw-rw---- 1 oragrid asmadmin 162,  4 May 13 10:08 raw4
crw-rw---- 1 oragrid asmadmin 162,  5 May 13 10:08 raw5
crw-rw---- 1 oragrid asmadmin 162,  6 May 13 10:08 raw6
crw-rw---- 1 oragrid asmadmin 162,  7 May 13 10:08 raw7
crw-rw---- 1 oragrid asmadmin 162,  8 May 13 10:08 raw8
crw-rw---- 1 oragrid asmadmin 162,  9 May 13 10:08 raw9


Reboot server to make sure you can see the raw devices as above.

md5sum csum fciv

LINUX: md5sum fileName

In Linux, the md5sum utility can be used:
aemtux1:/ % md5sum binary.file
0c4627e70d168f7f78257e6dd01fdb60 binary.file

This utility is provided by the following rpm package (the package name is the key element, because the version number depends on your Linux installation)
% rpm -qf /usr/bin/md5sum
coreutils-5.2.1-23.13


AIX: csum -h MD5 fileName

In AIX, there is no native "md5sum" but the MD5 hash function is provided by csum (provided and supported in AIX 5.3 and later):
csum -h MD5

aemaix1:/ % csum -h MD5 binary.file
0c4627e70d168f7f78257e6dd01fdb60 binary.file

Note: You may need to apply fixes to AIX for csum to handle files larger than 2 GB. For example:
IV03170: csum to support files more than 2GB APPLIES TO AIX 6100-07


Solaris: digest -a md5 -v fileName

In Solaris there is no native "md5sum", but "digest" can be used:

aemsun4:/ % digest -a md5 -v binary.file
md5 (binary.file) = 0c4627e70d168f7f78257e6dd01fdb60


HP-UX: md5sum fileName

HP-UX MD5 Secure Checksum 
Product details & specifications 
Overview 
The HP-UX MD5 Secure Checksum A.01.01.02 bundle (bundle name MD5Checksum) provides a file integrity utility and API based on the standard Message Digest 5 (MD5) algorithm. The MD5Checksum bundle consists of the following two components that can be installed independently: 
- HP-UX MD5sum (md5sum checksum command) 
- HP-UX LibCryptX (libcryptx libraries providing MD5 APIs) 
The md5sum command is based on the MD5 algorithm and generates 128-bit message digests. The md5sum command enables you to verify the integrity of files downloaded over a network connection. You can also use the md5sum command to compare files and verify the integrity of files. 


HP NonStop Server (NSS): md5sum fileName

In HP NonStop Server, the md5sum command is available in OSS.


Windows: md5sum fileName 
fciv -md5 fileName

Microsoft does not offer a supported tool for generating the MD5 hash.

There are 2 choices:

a) The md5sum utility can be found within the following package of useful utilities that were developed to mimic their corresponding peer in Unix. The UnxUtils.zip and UnxUpdates.zip packages contain such utilities. For details on the utilities that are provided in these packages and download links see:

GNU utilities for Win32

Example run:
H:\> md5sum binary.file
0c4627e70d168f7f78257e6dd01fdb60 *binary.file

b) Microsoft offers a NON-supported utility called "fciv":

Availability and description of the File Checksum Integrity Verifier utility
The File Checksum Integrity Verifier (FCIV) is a command-prompt utility that computes and verifies cryptographic hash values of files. FCIV can compute MD5 or SHA-1 cryptographic hash values. These values can be displayed on the screen or saved in an XML file database for later use and verification.

Example run:
H:\62570,379,000\2011-01-21> fciv -md5 binary.file
//
// File Checksum Integrity Verifier version 2.05.
//
0c4627e70d168f7f78257e6dd01fdb60 binary.file

Caveat:
During the writing of this technote, we found that the fciv utility worked fine in some Windows systems but failed in other systems with the following error. We could not find a way to overcome it. Thus, use this unsupported tool at your own risk.
Error during CryptAcquireContext.
Error msg : An internal error occurred.

Showing my time zone info with zdump

How do I show my time zone info? does it has any Daylight Saving Time? What is the detailed info?

You can find the binary zone file at /usr/share/lib/zoneinfo, browse around, and you can use the directory and file name as reference with command below.

From here, if the isdst=0 means Daylight Saving Time is OFF, and if isdst=1 means Daylight Saving Time is ON.

$ zdump -v Australia/West
Australia/West  Mon Jan 27 11:09:51 2014 CUT
Australia/West  Fri Dec 13 20:45:52 1901 GMT = Sat Dec 14 04:15:52 1901 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Dec 14 20:45:52 1901 GMT = Sun Dec 15 04:15:52 1901 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Oct 26 17:59:59 1974 GMT = Sun Oct 27 01:29:59 1974 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Oct 26 18:00:00 1974 GMT = Sun Oct 27 01:30:00 1974 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Mar  1 17:59:59 1975 GMT = Sun Mar  2 01:29:59 1975 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Mar  1 18:00:00 1975 GMT = Sun Mar  2 01:30:00 1975 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Oct 29 17:59:59 1983 GMT = Sun Oct 30 01:29:59 1983 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Oct 29 18:00:00 1983 GMT = Sun Oct 30 01:30:00 1983 CUT isdst=0 gmtoff = 27000
Australia/West  Sat Mar  3 17:59:59 1984 GMT = Sun Mar  4 01:29:59 1984 CUT isdst=0 gmtoff = 27000
….

Am I using Daylight Saving Time (DST)?
We could say if the time zone variable ends in DT (or in our case DFT), DST is enabled.


$ grep -i /etc/environment                 # or
$ echo $TZ
TZ=NFT-1DFT-2,M3.5.0,M10.5.0        # DST is used
TZ=CUT                                                   # DST is not used

SCP / SFTP / FTP file transfer ended with ^M (Control-M) characters

If you are like me, trying to transfer some ASCII files to a Linux / Unix machine.
But ended up the file being added modified with ^M characters at the end of each line as below:


Note:
- to get ^M type CTRL+V followed by CTRL+M
- UNIX style file (LF terminated)

- DOS style file (CRLF terminated)

If you are using SFTP or SCP to do the job, then you are out of your luck to have it settle on the fly.
There are some suggestion to use "sed" to remove those characters as below, but this adds extra jobs, and even worse if you are transferring numerous files at numerous directories.


If your destination Linux / Unix machine has the FTP service enabled, then you can probably just choose FTP client like Filezilla to transfer in ASCII mode for those files (Make sure you are using FTP protocol instead of SFTP or SCP). Or you may just choose to use "Automatic" file type transfer, since default setting will recognize most of the file type that

FTP supports switching between Binary and ASCII transfer mode and converting data on the fly but SFTP / SCP does not support that feature and it always transfers files unchanged

Common FTP client:
Nautilus
Konqueror
Filezilla
WinSCP
FireFTP
etc..


SAMBA Server disable CUPS

If you are seeing below in your /var/log/messages, and you are sure that you do not share any printing from your SAMBA server.

Aug 27 15:37:45 pmofilesvr smbd[21229]: [2013/08/27 15:37:45, 0] printing/print_cups.c:cups_connect(69)
Aug 27 15:37:45 pmofilesvr smbd[21229]:   Unable to connect to CUPS server localhost:631 - Connection refused
Aug 27 15:37:45 pmofilesvr smbd[21229]: [2013/08/27 15:37:45, 0] printing/print_cups.c:cups_connect(69)
Aug 27 15:37:45 pmofilesvr smbd[21229]:   Unable to connect to CUPS server localhost:631 - Connection refused

You may just disable it by having below in your smb.conf:

        load printers = no
        printcap name = /dev/null
        disable spoolss = yes

Test your config before reload or restart

        $ testparam -v

Reload or restart
        $ /etc/init.d/smb reload
        $ /etc/init.d/smb restart

Now check your log file if log above still persists.

Redhat Enterprise Linux enable core dump

1. To check current configuration for core dump. Zero means core dump was disabled.

$ ulimit -c
0

2. To enable system wide core dump, edit /etc/profile as below:

# No core files by default
#ulimit -S -c 0 > /dev/null 2>&1
ulimit -S -c unlimited > /dev/null 2>&1

3. specify core dump file location
Add it to /etc/sysctl.conf, and make sure to reload the config using "sysctl -p"

kernel.core_pattern = /tmp/core

4. To limit users from having unlimited core dump that causes file system full.
Edit /etc/security/limits.conf as below (value was in KB), disable all users, only allow for specific users with size limit:

*         hard    core            0
userA hard    core            512000

5. To confirm the configuration, log out from current session, relogin and try below.
start a new process or just edit a file using vim, grep the PID and check below (you need to have a new process to have this new setup):

(userA process)
[root@server1 ~]# cat /proc/8865/limits 
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            10485760             unlimited            bytes     
Max core file size        0                    524288000            bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             unlimited            unlimited            processes 
Max open files            1024                 1024                 files     
Max locked memory         32768                32768                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       40960                40960                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    
Max realtime priority     0                    0   

(Other user process)
[root@server1 ~]# cat /proc/30376/limits 
Limit                     Soft Limit           Hard Limit           Units     
Max cpu time              unlimited            unlimited            seconds   
Max file size             unlimited            unlimited            bytes     
Max data size             unlimited            unlimited            bytes     
Max stack size            10485760             unlimited            bytes     
Max core file size        0                    0                    bytes     
Max resident set          unlimited            unlimited            bytes     
Max processes             40960                40960                processes 
Max open files            1024                 1024                 files     
Max locked memory         32768                32768                bytes     
Max address space         unlimited            unlimited            bytes     
Max file locks            unlimited            unlimited            locks     
Max pending signals       40960                40960                signals   
Max msgqueue size         819200               819200               bytes     
Max nice priority         0                    0                    

Max realtime priority     0                    0  


Reference:
https://access.redhat.com/site/solutions/5352
https://access.redhat.com/site/solutions/4058
http://linuxtechres.blogspot.com/2011/09/how-to-enable-core-dump-for-application.html

dos2unix: removing CRLF characters

If you have just copied a script created/edited from Windows text editors, and tried to run the script in Linux. You get below:

[anthony@fc18 tested_examples]$ ./getinfo.sh 
bash: ./getinfo.sh: /bin/bash^M: bad interpreter: No such file or directory

Now try to confirm your text file content:

[anthony@fc18 tested_examples]$ file getinfo.sh 
getinfo.sh: Bourne-Again shell script, ASCII text executable, with CRLF line terminators

if you get those CRLF line terminators, you will need to remove them.
Easiest way is to install the dos2unix package from YUM and run as below:

[anthony@fc18 tested_examples]$ dos2unix getinfo.sh 
dos2unix: converting file getinfo.sh to Unix format ...

And you will have your file clean.

output texts in columns

If you have a list of data that needs to be printed out in a proper align column format. you can use the "column" command to sort them out.

refer as below:


Linux cron: /tmp/crontab.XXXX file

I noticed some files under /tmp with the name of crontab.XXX as below:

-rw-------  1 anthony  root      949 Jul 11 09:10 crontab.XXXXS2IaZU
-rw-------  1 anthony  root      950 Jul 11 09:10 crontab.XXXXSNwiwK

What are those?

These are the temp file created when you issued the crontab -e command.
Possible single crontab being edited by 2 different session?

Anyhow, these files can be remove, just make sure you got your effective cron being stored under /var/spool/cron folder.

Linux cron entry: ORPHAN (no passwd entry)

I saw an entry in my /var/log/cron file as below:


Jul 10 08:01:01 server1 crond[3420]: (tmp.XXXXEXYFUw) ORPHAN (no passwd entry) 

What could be the possible meaning of this?

This will occur if there's a file in the /var/spool/cron directory that doesn't match up to a username and UID. So if you find /var/spool/cron/anthony --you must be able to 'id anthony'. Or you can just grep from /etc/passwd file.

One of the reason could be as a result of creating a backup file for root /var/spool/cron/anthony.back. Since there is no UID for user "anthony.back" then it's considered ORPHAN.

Make sense? Here's the code --this conditional has probably not changed for years...

if (strcmp(fname, "*system*") && !(pw = getpwnam(uname))) {
/* file doesn't have a user in passwd file.
*/
log_it(fname, getpid(), "ORPHAN", "no passwd entry");
goto next_crontab;
}

running a cron at every month end


If tomorrow's date is 01, condition will be true and it will execute subsequent command.
55 23 * * * [ `date -d tomorrow +\%d` -eq '01' ] && /path/to/script


passwordless sudo (not recommended!!)

add your user account to be part of admin and sudo group.
And change the entry as below:
(NOTE: not a best practice for system security in mind, but happy for those lazy-to-type-password like me..)

$ sudo visudo
# Members of the admin group may gain root privileges
%admin ALL=(ALL) NOPASSWD:ALL

# Allow members of group sudo to execute any command
%sudo    ALL=(ALL) NOPASSWD:ALL

Ubuntu Change Preferred Default Boot Order

You have dual boot system; Ubuntu and Win7.
And you like to auto boot into the previous booted system.

Change GRUB_DEFAULT to "saved" and GRUB_SAVEDEFAULT to "true"

$ sudo vi /etc/default/grub
#GRUB_DEFAULT=0
GRUB_DEFAULT=saved
GRUB_SAVEDEFAULT=true
#GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
GRUB_CMDLINE_LINUX=""


$ sudo update-grub
 
Now do a reboot and give it a try


change default editor in Ubuntu

Just installed Ubuntu, and tried to edit some files, but nano came out?
Not used to nano editor?

Change it to your preferred editor (vim in our case).

$ sudo update-alternatives –config editor
$ sudo update-alternatives –config editor
There are 5 alternatives which provide `editor’. 
Selection Alternative
———————————————–
1 /usr/bin/vim
2 /bin/ed
*+ 3 /bin/nano
4 /usr/bin/vim.basic
5 /usr/bin/vim.tiny
Press enter to keep the default[*], or type selection number: 

 

slow initial SSH connection


Symptom:

[anthony@fc18 ~]$ ssh -l userA 10.10.10.1 -v
OpenSSH_6.1p1, OpenSSL 1.0.1e-fips 11 Feb 2013
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 50: Applying options for *
debug1: Connecting to 10.10.10.1 [10.10.10.1] port 22.
debug1: Connection established.
debug1: identity file /home/anthony/.ssh/id_rsa type -1
debug1: identity file /home/anthony/.ssh/id_rsa-cert type -1
debug1: identity file /home/anthony/.ssh/id_dsa type -1
debug1: identity file /home/anthony/.ssh/id_dsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.3
debug1: match: OpenSSH_4.3 pat OpenSSH_4*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.1
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024 p="" sent="">debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host '10.10.10.1' is known and matches the RSA host key.
debug1: Found key in /home/anthony/.ssh/known_hosts:12
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received

#### connections seems to be hanging starting from here for more than 5 seconds #####

debug1: Authentications that can continue: publickey,password
debug1: Next authentication method: publickey
debug1: Trying private key: /home/anthony/.ssh/id_rsa
debug1: Trying private key: /home/anthony/.ssh/id_dsa
debug1: Next authentication method: password
gzchin@10.10.10.1's password:

Resolution:
If your server does not has any Internat access / DNS server for name resolution.
Set this in sshd_config and restart SSHD server.

    UseDNS no


PMTU (Path MTU) Discovery


Summary

Internet computers, mostly servers, sometimes send packets too large for part of a given path.  Not handling this correctly can make the server unusable for some people.
Correct handling of oversize packets is by one of two means, as chosen by the sending computer (the server):

Permitting Packet fragmentation - used mostly by older systems
Path MTU discovery - asking for ICMP notification when fragmentation would be needed

By default, modern servers disable fragmentation (DF) and try to use path MTU discovery, but sometimes the system administrators block the ICMP notifications.  Overall, these servers ask for ICMP notification of packets that are too large and then refuse to accept the notifications they ask for.
Unable to learn that they are sending packets are too big for some paths, the servers are unable to send data to some users.  To overcome this they need to accept appropriate ICMP types or allow fragmentation.

Path MTU Discovery

Every network link has a maximum packet size called the link's MTU (Maximum Transmission Unit).  The full path from one computer to another may travel across many links with different MTUs.  The smallest MTU for all the links in a path is the path MTU.

If a packet starts out on a network segment with a large MTU, it may arrive at a link with a smaller MTU and be too big to fit.  Most servers are on segments with large MTUs, but it is increasingly common for internet users to be connected via links with reduced MTUs, so it is becoming common for some packets to be too big.

How the problem of oversize packets has been handled has evolved considerably over time.  The original approach was to send only small packets corresponding to the TCP/IP default MTU (576 bytes).  (To this day, a sending system needs permission from the receiving system to send larger packets, but that permisssion is given as a matter of routine.)

For some packets, especially those sent by older equipment, an oversize packet can be sent by breaking it into fragments and sending the fragments as smaller packets.  The fragments can be reassembled downstream to reconstruct the original large packet, but this packet fragmentation has several problems involving both efficiency and security.

Newer servers try to optimize their transmissions by discovering the path MTU and sending packets of the maximum size when there's enough data to fill them. The procedure for doing this was standardized and published as RFC 1191 in 1990, but it did not become widely deployed until years later. By mid 2002, 80% to 90% of computers on the internet used path MTU discovery.

The basic procedure is simple - send the largest packet you can, and if it won't fit through some link get back a notification saying what size will fit.  The notifications arrive as ICMP (Internet Control Message Protocol) packets known as "fragmentation needed" ICMPs (ICMP type 3, subtype 4).  The notifications are requested by setting the "do not fragment" (DF) bit in packets that are sent out.

Some network and system administrators view all ICMPs as risky and block them all, disabling path MTU discovery, usually without even realizing it.  Of the several dozen ICMP types and subtypes, some do pose some risk, but the risk is mostly mild and is of the "denial of service" nature.  That is, an attacker can use them to interfere with service on and from the network.

By blocking all ICMPs the administrator himself interferes with service on and from his own network.  Unless he also turns off path MTU discovery on his network's servers, he makes his servers unusable by users with reduced-MTU links in their paths.  Because service is affected only in relatively unusual cases, it can be difficult to convince the administrator that a problem exists.  The prevalence of such "unusual" cases is growing rapidly though.

Administrators who want to block all ICMPs should disable path MTU discovery on their computers, especially on their servers. It makes no sense to ask for ICMP notifications and then refuse to accept them.  In addition, doing so opens the server to a special type of distributed denial of service attack based on resource exhaustion from a large number of fully-open connections.

Path MTU discovery can be turned off:


Disabling path MTU on Windows systems requires modifying the Windows Registry.  Microsoft's support website has information and cautions about the Registry.
Recommended to use the Dr. TCP utility for Windows.


Under Linux, with the command
    echo  1  >/proc/sys/net/ipv4/ip_no_pmtu_disc

Under FreeBSD, by using sysctl(8) to zero
    tcp.path_mtu_discovery

On Cisco routers,with the configuration command
    no ip tcp mtu-path discovery

Example Path MTU Discovery Failure Scenario

Joe User has a DSL line.  Like many DSL lines, Joe's line actually comes from a large DSL wholesaler and uses PPPoE (PPP over Ethernet) to create a logical channel between Joe and his favorite ISP.  The DSL line physically connects to a small PPPoE router with a built-in hub, which Joe uses as the basis for his home network.

The MTU on Joe's network is Ethernet's usual 1500 bytes.  The MTU on his DSL line is also 1500 bytes, but PPPoE uses 8 of these bytes for an 8-byte PPPoE header, so the MTU of his PPPoE channel to his ISP is only 1492 bytes.

A computer on Joe's Ethernet doesn't know about the PPPoE channel.  The largest packet it can receive is a 1500-byte Ethernet packet, so when Joe uses his computer to connect to a remote server, his computer tells the server it's ok to send packets up to 1500 bytes.[*]

Establishing connections uses only very small packets, so Joe can connect to the server without any MTU issues, but as soon as Joe asks for enough data to fill a 1500-byte packet, the server sends a 1500-byte packet.  When that packet gets to Joe's ISP, it doesn't fit down the PPPoE channel.  The packet has the DF bit set, telling Joe's ISP to drop the packet and send the server an ICMP saying what packet size will fit.  The ISP sends an ICMP saying the largest size is 1492 bytes.

If the server gets that ICMP, it re-sends the first 1492 bytes as a new packet.  This new packets fits down the PPPoE channel, so Joe's computer gets it and sends back an acknowledgement.  The server continues sending 1492-byte packets until Joe has what he asked for.  In most cases the server will remember the reduced path MTU, typically for ten minutes, and use it for future connections from Joe's computer.

However, if the server does not get that ICMP, things go downhill fast.  The server is expecting an acknowledgement from Joe's computer, but Joe's computer didn't get the packet, so the acknowledgment never comes.  After awhile, the server gives up waiting and sends the same 1500-byte packet again.  Joe's ISP sends back another ICMP.  The server doesn't get it again and tries sending the 1500-byte packet a third time, then a fourth, a fifth, and so on.

Meanwhile Joe's computer can't tell this is happening and is waiting for a response from the server.  Eventually, it gives up and sends the server a connection reset.  It reports a network failure to Joe, who is left wondering what happened.  He may soon discover he can access nearly all other sites, just not the one he wanted.

If the server he's trying to access is a web server, he may get part of the website, such as getting the ads but not the main page content.  This happens because the pages normally displayed for many websites are assembled from data obtained from multiple servers on a variety of networks.  The networks dispensing the ads all support path MTU discovery.

If Joe complains to the server operator, they may tell him the problem has to be his ISP because other users can view their server.  However, Joe's ISP is not doing anything wrong, but the server operator is.  PPPoE and other connections with reduced MTUs are perfectly legitimate and increasingly common. Having a server ask for ICMP notification that it refuses to accept is what's broken behavior.  Some later day, when the server site has gotten enough complaints from people like Joe to believe something is wrong, it may either stop asking for the ICMPs or start accepting the useful ones.  Then Joe will be able to access it.

[*] What Joe's computer actually tells the remote server is that the largest payload it can send in any packet is 1460 bytes, which is the 1500-byte maximum Ethernet packet size minus 40 bytes of overhead.  This maximum payload is called the MSS (Maximum Segment Size).

Workarounds

There is something Joe can do in the meantime.  He can reduce the MTU setting on his computer's Ethernet interface to the PPPoE MTU, 1492 bytes.  Then when his computer first connects to the server, the maximum allowed packet size it gives the server will be 1492 bytes, and the server's packets will fit down the PPPoE channel.
In other words, if he is knowledgeable enough, Joe can overcome the server network misconfiguration by doing manually what is supposed to happen automatically.

If Joe's computer is a Windows system, changing his MTU requires changing a Windows Registry setting.  This is normally something that only experienced Windows-savvy users should attempt.  However, misconfigured servers causing path MTU discovery problems for DSL users has become common enough that there are Windows "tuning" programs available that will do this.

If Joe runs Linux or another UNIX variant, setting the MTU is much easier, using the "ifconfig" command.  However, Linux (and perhaps other UNIX variants) has something even better.  He can reduce the MTU for only his default route out the PPPoE/DSL channel while continuing to use the full 1500-byte MTU for traffic on his own network.

Tunnels and Path MTU Discovery

[**] A tunnel having an MTU of 1500 when it's carried by packets on a link with reduced MTU is possible because PPP is level 2 even though it is encapsulated in level 3 TCP.  PPP fragmenting packets is analogous to ATM shredding of packets and does not violate IP semantics.  PPPoE could do this too, but apparently it does not.  (If you didn't understand this paragraph, don't worry about it.)

Unix not a recognized terminal type



After you log into a Unix server (AIX for example).
You get the error about terminal type when you try to vi or example below when try to edit crontab.

$ crontab -e
ex: 0602-108 xterm-256color is not a recognized terminal type.
  [Press return to continue]

# check your current TERM value

$ env | grep TERM
TERM=xterm-256color

# set to new TERM value to fix
export TERM=vt100

You will need to add to your startup file to something like below:
$ cat .profile



PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:.

export PATH
export TERM=vt100

if [ -s "$MAIL" ]           # This is at Shell startup.  In normal
then echo "$MAILMSG"        # operation, the Shell checks
fi                          # periodically.



MAILX: to send mail out from Linux cmd with attachment.


1. create a file under your user profile with contents below:
$ vi /home/user1/.mailrc

Contents:
account admin {
set from="admin@serverA.com"
set smtp=192.168.1.1:25
}

2. run from cmd
$ echo "test mail content" | mail -A admin -a file.jpg -s "test mail" abc@abc.com"