Compress Whitespace With tr Shell Command
To replace all whitespace with single spaces pipe the text through:
|
1 |
tr -s [[:space:]] " " |
To replace all whitespace with single spaces pipe the text through:
|
1 |
tr -s [[:space:]] " " |
Here’s how to filter or block ICMP timestamp requests and replies. On Redhat/CentOS, edit /etc/sysconfig/iptables and add the following lines
|
1 2 3 |
-A RH-Firewall-1-INPUT -p ICMP --icmp-type timestamp-request -j DROP -A RH-Firewall-1-INPUT -p ICMP --icmp-type timestamp-reply -j DROP |
and then run:
|
1 2 |
/sbin/iptables restart |
Or run the following commands:
|
1 2 3 4 |
/sbin/iptables -I RH-Firewall-1-INPUT 1 -p ICMP --icmp-type timestamp-request -j DROP /sbin/iptables -I RH-Firewall-1-INPUT 1 -p ICMP --icmp-type timestamp-reply -j DROP /sbin/service iptables save |
Recently on an Ubantu server we just added these lines to /etc/rc.local:
|
1 2 3 4 |
/sbin/iptables -I INPUT 1 -p ICMP --icmp-type timestamp-request -j DROP /sbin/iptables -I INPUT 1 -p ICMP --icmp-type timestamp-reply -j DROP |
Add the following line to /etc/profile to setup full logging of all ssh sessions: script -q /var/log/sessions/ssh-date +%d-%M-%Y-%Hh-%Mm-%Ss–whoami-$$.log && exit Of course this is a security risk and violates user privacy.
lftp support ftps (different from sftp). ftps is ftp over an explicit TLS (SSL) connection. We’ve seen a few sites running MS IIS that require ftps and getting lftp to work has been tricky. To make it work verify that your lftp build has gnutls support compiled in with:
|
1 |
lftp -v |
This build does not:
|
1 |
Libraries used: Readline 5.1, Expat 1.95.8, OpenSSL 0.9.8d 28 Sep 2006 |
Here’s one that does:
|
1 |
Libraries used: Readline 5.1, Expat 1.95.8, GnuTLS 2.6.6, zlib 1.2.3 |
Once you have have TLS support in your lftp build then you can put a file with something like this:
|
1 2 3 4 5 6 |
lftp -c 'open -e "set ftps:initial-prot ""; \ set ftp:ssl-force true; \ set ftp:ssl-protect-data true; \ put test.txt; " \ -u "USERNAME","PASSWORD" \ ftps://HOSTNAME:990 ' |
The option sets are critical as lftp wants to do “PROT C” by default but Windows wants to see “PROT P”.
Here’s an lftp script to rename a remote file vi FTP without downloading the file:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/bin/bash NAS_HOST=myhost NAS_USER=myuser NAS_PASS=mypass SRC=$1 DST=$2 lftp -c "open -e \"mv $SRC $DST\" -u $NAS_USER,$NAS_PASS $NAS_HOST" |
Reliable Penguin provides managed web hosting, systems administration, website and server migrations, and expert consulting.
Submit the form—or for immediate service call 866-649-7984.