Host's key could be changed in many cases.
It's a good idea to ignore host's key if no security issues.
Add following options to ssh and scp commands to do so.
Linux / Cygwin
-o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no"
Windows
-o "UserKnownHostsFile=NUL" -o "StrictHostKeyChecking=no"
Xyberbit Linux
2019年12月1日 星期日
2019年11月5日 星期二
[ Cygwin64 ] - TeraTerm connection?
1. Switch to TeraTerm directory.
2. Replace the original 32-bit cygterm by 64-bit one from cygterm+-x86_64 directory.
2. Replace the original 32-bit cygterm by 64-bit one from cygterm+-x86_64 directory.
2019年10月29日 星期二
[ Shell ] assign value
Pipeline invokes sub-shell and all changes won't be recorded, a famous bash example:
cat file | while read line; do var_in_pipe="$line"; done
And var_in_pipe never given values, so use redirect instead.
while read line; do var_no_pipe="$line"; done < file
cat file | while read line; do var_in_pipe="$line"; done
And var_in_pipe never given values, so use redirect instead.
while read line; do var_no_pipe="$line"; done < file
2019年10月26日 星期六
2019年10月21日 星期一
[ Patch ] diff and patch
diff -u original modded > mod.patch
-N : absent files as empty.
-a : text mode
-r : directory recursively
patch -p N < mod.patch
-p N : strip N leading components from file names
N=0 if diff and patch were performed under the same directory
-N : absent files as empty.
-a : text mode
-r : directory recursively
patch -p N < mod.patch
-p N : strip N leading components from file names
N=0 if diff and patch were performed under the same directory
2019年9月20日 星期五
[ Ethtool ] MAC update
As long as NIC driver supports the EEPROM can be updated via ethtool.
It's convenient on production line if the EEPROM is not well pre-burnt.
Ethtool write a byte:
ethtool -E $eth magic $mgc offset $off value $bye
mgc = magic composed by devID and venID, "lspci -n" to discover it
bye = byte to write
eth = ether device name, "ifconfig" to discover it
off = writing offset in EEPROM
A for loop can easily update the MAC address.
Example of updating Intel i210 MAC under CentOS
mgc=0x15338086
mac=00:11:22:33:44:55
eth=enP6p1s0
off=0
for i in {0..5}; do ethtool -E $eth magic $mgc offset $((off+i)) value 0x${mac:$((i*3)):2}; done
Checking the result by reading EEPROM.
ethtool -e $eth offset $off length 6
It's convenient on production line if the EEPROM is not well pre-burnt.
Ethtool write a byte:
ethtool -E $eth magic $mgc offset $off value $bye
mgc = magic composed by devID and venID, "lspci -n" to discover it
bye = byte to write
eth = ether device name, "ifconfig" to discover it
off = writing offset in EEPROM
A for loop can easily update the MAC address.
Example of updating Intel i210 MAC under CentOS
mgc=0x15338086
mac=00:11:22:33:44:55
eth=enP6p1s0
off=0
for i in {0..5}; do ethtool -E $eth magic $mgc offset $((off+i)) value 0x${mac:$((i*3)):2}; done
Checking the result by reading EEPROM.
ethtool -e $eth offset $off length 6
2019年9月17日 星期二
[ SSH ] remote unattended
sshpass -p <password> ssh -q -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no" <user id>@<remote IP> "<command(s)>"
Cygwin works as well.
Cygwin works as well.
2019年8月20日 星期二
[ Shell ] sourced?
A quick thought is using $0 and $_ as follow, but many exceptions.
[ "$0" != "$_" ] && echo Sourced
A better version to tell sourced condition, but still doesn't cover all cases.
[ "$0" = "`ps p $$ o cmd=`" ] && echo Sourced
Finally a perfect solution, cheers!
[ "$0" != "$_" ] && echo Sourced
A better version to tell sourced condition, but still doesn't cover all cases.
[ "$0" = "`ps p $$ o cmd=`" ] && echo Sourced
Finally a perfect solution, cheers!
[ "`cat /proc/$$/cmdline`" = "$0" ] && echo Sourced
However /proc/$$/cmdline may contain zero characters and grep may not support -z option, so revised again, almost universal now.
[ "`cat /proc/$$/cmdline | xargs -0 echo`" = "$0" ] && echo Sourced!
Under bash there is a quick way to exit without quitting the console:
return X >&/dev/null || exit X
or
eval "return X >&/dev/null; exit X"
Where X is the exit code, assume sourced and simply returns, if failed, do exit.
Form 2 is treated as an executive unit instead of two separate commands compared to form 1 and is useful in complicated conditions which form 1 won't work, says:
[ ... ] && command 1 && command 2 && eval "return X >&/dev/null; exit X"
return X >&/dev/null || exit X
or
eval "return X >&/dev/null; exit X"
Where X is the exit code, assume sourced and simply returns, if failed, do exit.
Form 2 is treated as an executive unit instead of two separate commands compared to form 1 and is useful in complicated conditions which form 1 won't work, says:
[ ... ] && command 1 && command 2 && eval "return X >&/dev/null; exit X"
訂閱:
文章 (Atom)
[SSH & SCP] ignore known hosts
Host's key could be changed in many cases. It's a good idea to ignore host's key if no security issues. Add following options ...
-
ps p $$ o comm=
-
As long as NIC driver supports the EEPROM can be updated via ethtool. It's convenient on production line if the EEPROM is not well pre-...