2020年12月30日 星期三

2020/12/27 2020台灣國際馬拉松賽 我愛新竹

 2020/12/27完成我的第一次全程馬拉松,對我這個運動肉腳來說,真是不可思議的一件事。


2020年12月18日 星期五

SQL Server Transaction Log Shrink

 Reference:

[SQL] 交易記錄檔 LDF 太大 (趴兔) - 使用 DBCC Shrinkfile

SQL Server Transaction Log Backup, Truncate and Shrink Operations

SQL DB的檔案有兩個:

*.MDF 資料檔

*.LDF 記錄檔


如果有正常備份成功,LDF內的log應該會刪除。如果有其他因素造成log持續成長,會把硬碟塞滿。這時候只能把log清除並壓縮LDF。

作法:

  • 將資料庫復原模式設成「簡單」
  • 執行 DBCC SHRINKFILE (DBname_log, 2)
  • 將資料庫復原模式設成「完整」

2020年12月16日 星期三

查看 DLL 內容的工具

 Reference:

How to open .dll files to see what is written inside?

方法一:Visual Studio

  • 在Visual Studio 2019的Developer Command Prompt for VS 2019中,
  • 執行 ILDASM



方法二:ILSPY (open source)

http://ilspy.net/


網頁弱點偵測工具

 Reference:

OWASP ZAP Attack Proxy

網頁滲透測試工具──OWASP ZAP

ZAP 2.12.0安裝方式請看這一篇

安裝:

OWASP ZAP下載及安裝

並安裝Firefox browser

使用方式:


2020年12月7日 星期一

Windows 2016 無法連上 IPCAM

狀況:

有一支IPCAM網路port 8120,用Windows 7連線正常,但是用Windows 2016連不上。已排除Firewall網路權限問題,因為把W2016的IP改為W7的IP還是無法連線。重新裝一台W2016把Windows Firewall, Defender關閉還是連不上。


解法:

在W2016用 administrator 執行 netsh int tcp set global ecncapability=disabled

PS. 用 netsh int tcp show global 可以查看目前設定


原因:

請參考這一篇。

問題:OGServer安裝在Windows Server 2012或R2時,為何有些TCP的設備會發生頻繁的斷連線?






2020年12月3日 星期四

SQL injection 測試方法及工具

 Reference:

資安滲透攻防筆記-1

sqlmap®

Using sqlmap for testing HTTPS sites

使用工具 SQLMAP 檢測

安裝在CentOS 7,步驟:

  • yum install python
  • yum install git
  • git clone --depth 1 https://github.com/sqlmapproject/sqlmap.git sqlmap-dev
  • yum install squid
  • service squid start

執行:

  • cd sqlmap-dev/
  • ./sqlmap.py -u "https://target.com/" --batch
  • 若網頁需要輸入資料,指令 ./sqlmap.py -u "https://target.com/" --batch --forms

(2021.7.13 version update後似乎不需要 --batch --proxy "http://127.0.0.1:3128")

  • ./sqlmap.py -u "https://target.com/" --batch --proxy "http://127.0.0.1:3128"


IIS disable debug reporting

 Reference:

停用 ASP.NET 應用程式的調試


弱點掃描結果:

Nonexistent Page (404) Physical Path Disclosure

2020年11月28日 星期六

2020/11/28 走讀竹塹古城跡

 

忘了開運動APP,找Google時間軸頂一下。四個紅色標示是城門的位置,感謝跑友劉老師開團,來新竹這麼多年只知道東門 ^___^

2020年11月15日 星期日

2020/11/15 新竹戀戀桐花路跑

原本四月的戀戀桐花路跑,因為新冠病毒疫情延到11月。

11月理論上應該是會冷,沒想到天氣居然意外的好。早上很涼爽,接近八點時太陽出來還有點熱。

今年半馬的路線是新的,以前跑友說路都平平的、只有兩個坡、上坡和下坡,這個新路線真的只有兩個坡,一路大爬坡上到最高點,然後一路陡下坡回來,好硬的路線~~~

去年成績2:33:13,今年成績2:30:02,新路線大爬坡居然還可以進步3分鐘,可喜可賀!

主辦單位:中華民國陸上運動競技協會

比賽地點:合興愛情車站

2020年11月3日 星期二

Solaris Hostid 設定

 Reference:

How to Change the Hostid In Solaris

Step 1: Convert Hostid 850168ae<hexdecimal format> to Decimal format <2231462062>

http://www.easycalculation.com/hex-converter.php

sample convert 850168ae<hexdecimal format> to 2231462062 <Decimal format >

Step 2: Convert Decimal format <2231462062> to Hex Value format <32 32 33 31 34 36 32 30 36 32>

http://www.easycalculation.com/ascii-hex.php

sample convert 2231462062<Decimal format> to 32 32 33 31 34 36 32 30 36 32 <Hex Value format>

Step 3: backup S20sysetup with #cp /etc/rc2.d/S20sysetup to /etc/rc2.d/S20sysetup.old

Step 4: Change the /etc/rc2.d/S20sysetup file & save

在最後一行加上

echo "hw_serial/v 32 32 33 31 34 36 32 30 36 32 00 00" | mdb -kw

Step 5: Run #sh S20sysetup or ./S20sysetup or reboot Machine



2020年10月28日 星期三

sshpass sftp

Reference:

 如何使用Bash脚本中的密码运行sftp命令?


sshpass -p <mypasswd> sftp user@sftp.mydomain.com > ${LOG}/filename.log <<!

cd /from_ch

ls -ltr

bye

!


2020年10月24日 星期六

2020/10/24 第十二屆遠東新世紀盃經典馬拉松賽

天氣涼爽,但風超大~~~

第十屆有魔王大上坡,第十一屆路平平的。

今年第十二屆除了魔王大上坡還延伸到箭竹窩,超級陡的!回程在河邊一路逆風,眼睛都睜不開了~~~

成績比去年慢1分鐘,不過今年多了魔王上下坡,所以應該算有一點進步吧。

2020年10月23日 星期五

SunOS / Solaris printer setup

List printer: lpstat -s


Add printer: 

SunOS 4

Edit /etc/printcap

Ex: 

lp|lw|ps|postscript|PostScript:\

        :lp=:rm=m5191:rp=aux:sd=/var/spool/lpd:


SunOS 5

透過Xwindow,指令admintool



Reference:

https://docstore.mik.ua/orelly/networking_2ndEd/tcp/ch09_02.htm




2020年9月2日 星期三

Disable weak versions of SSL/TLS Protocols on Windows Server 2012 R2

 Reference:

Microsoft IIS: Disabling the SSL v3 Protocol

How to Enable TLS 1.2 as the Default Security Protocol on Windows Servers

How to disable weak versions of SSL/TLS Protocols on Windows Servers


Windows 2012 R2 預設有 SSL 2.0, SSL 3.0, TLS 1.0, TLS 1.1, TLS 1.2,只保留 TLS 1.2 其餘關閉。

步驟:

執行 regedit.exe,切換到 HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\Schannel\Protocols\

新增機碼,沒有的就手動加上

SSL 2.0\Server\Enabled = 0 (Dword)

SSL 2.0\Client\DisabledByDefault  = 1 (Dword)

SSL 3.0\Server\Enabled = 0 (Dword)

SSL 3.0\Client\DisabledByDefault  = 1 (Dword)

TLS 1.0\Server\Enabled = 0 (Dword)

TLS 1.0\Client\DisabledByDefault  = 1 (Dword)

TLS 1.1\Server\Enabled = 0 (Dword)

TLS 1.1\Client\DisabledByDefault  = 1 (Dword)

重開機後生效。

驗證:

用 https://www.ssllabs.com/ssltest/ 確認狀態



2020年8月11日 星期二

Outlook 2010 to Office365 via Squid proxy

 狀況:

Outlook 2010 連到 Office 365 等很久 (狀態顯示:嘗試連線),最後會連線成功。


原因:

Squid proxy 預設安裝只有 http proxy,對於其他 port 是建立 tunnel。


解法:

啟用Squid SSL bump,將 Office 365 的網域加入 ssl_exclude_domains.conf


步驟:

1. Create CA certificate and key for SSL bump

cd /etc/squid

mkdir ssl_cert

chown squid:squid ssl_cert

chmod 700 ssl_cert

cd ssl_cert

openssl req -new -newkey rsa:2048 -sha256 -days 3650 -nodes -x509 -keyout myCA.pem  -out myCA.pem

2. Generate DH parameters in '/etc/squid' folder

openssl dhparam -outform PEM -out dhparam.pem 2048

3. extract certificate for importing in browsers

openssl x509 -in myCA.pem -outform DER -out myCA.der

4. Edit '/etc/squid/squid.conf' and use following before 'http_access deny all' rule

# Enable SSL bump

#acl step1 at_step SslBump1

#acl step2 at_step SslBump2

#acl step3 at_step SslBump3

acl ssl_exclude_domains ssl::server_name "/etc/squid/ssl_exclude_domains.conf"

acl ssl_exclude_ips     dst              "/etc/squid/ssl_exclude_ips.conf"


#ssl_bump splice localhost

#ssl_bump peek step1 all

ssl_bump splice ssl_exclude_domains

ssl_bump splice ssl_exclude_ips

#ssl_bump stare step2 all

#ssl_bump bump all


# And finally deny all other access to this proxy

http_access allow all

#http_access deny all

#http_port 3128
http_port  3128 ssl-bump generate-host-certificates=on dynamic_cert_mem_cache_size=16MB cert=/etc/squid/ssl_cert/myCA.pem

5. Edit /etc/squid/ssl_exclude_domains.conf
.office365.com
.outlook.com

Reference:

Feature: SslBump Peek and Splice

在 Squid 服務中配置 SSL Bumping

Configure squid-3.3 in transparent mode on CentOS 7 with SSL bump

How to enable HTTPS decryption (SslBump) in Squid 3.5 for Windows?


PS. 我的環境如果勾 近端網址不使用Proxy伺服器,Outlook還是會等很久。


2020年8月2日 星期日

2020/8/2 Zepro run 新竹場

因為新冠病毒疫情,從 2020/3/29 延期到 8/2。
夏天真的好熱,我到15K就放棄了,走了好一段再慢慢蛇回來。
就像人生,遇到困難只能靠自己。

本來就預計用這一場測試有沒有可能跑全馬。
如果成績不錯就報名今年 12/27 台灣國際馬拉松賽(我愛新竹) 的全馬。
看今天的成績我不敢報名了,勉強參加的話可能會超過關門時間吧。

2020/8/1湖口愛跑團三周年團慶

這次坐跑友的車到湖口,還滿快就到了。
去年自己騎機車,大約要30分鐘。
恭喜湖口愛跑團生日快樂。


2020年7月3日 星期五

查詢 Android 手機記憶體 RAM 使用狀況

Reference:
教程:如何在原生 Android 8.0 系統上查看 RAM 使用空間;這方法 Nokia 8、Google Pixel、Nexus 皆能用!

調出原生 Android 8.0 系統 RAM 顯示步驟

  1. 首先大家得去手機【設定 / Setting】-【系統 / System】-【關於手机/ About Phone】-【版本號碼/ Build Number】

  2. 然後在【版本號碼/ Build Number】連續按 7 下,這時您就能啟動【開發人員選項/ Developer Options】了。

  3. 返回【系統 / System】,這時您應該看到【開發人員選項/ Developer Options】出現在列表中。

  4. 點入【開發人員選項/ Developer Options】您就會看到【記憶體/ Memory】出現,點入 Memory 就能查看手機 RAM 剩多少了!


看了才知道我的RAM都給一個遊戲吃掉了~~~

2020年6月23日 星期二

Get disk usage via snmpwalk

Reference:
[網管應用] Windows系統的snmp測試工具 - snmpwalk
Install or configure SNMP for Windows
Windows 透過 snmp 監控系統資源的方法
Linux系統監控常用到的SNMP OID
How do you get snmpwalk to return numeric oids instead of MIB resolutions?

安裝 snmpwalk
for Linux: yum install yum install net-snmp-utils
for Windows: 從這裡下載 https://www.snmpsoft.com/cmd-tools/snmp-walk/

Windows server 設定 snmp service
Install or configure SNMP for Windows

Linux 設定 snmp service
yum install net-snmp
vi /etc/snmp/snmpd.conf
增加一行 view    systemview    included   .1
將 disk / 10000 的 # 拿掉
service snmpd restart

Windows Disk usage 指令
snmpwalk -v2c -c public hostname .1.3.6.1.2.1.25.2

Linux Disk Usage 指令
snmpwalk -v 1 -c public hostname .1.3.6.1.4.1.2021.9.1

2020/7/4 update:
Reference: snmpwalk parameter

snmpwalk 執行後,查出一部分資料就Timeout: No Response from。(如下圖)
加上 -t 10 減少 timeout 狀況。
Ex: snmpwalk -v2c -t 10 -c public hostname .1.3.6.1.2.1.25.2



2020年6月20日 星期六

excel odbc 驅動程式管理員 找不到資料來源名稱且未指定預設的驅動程式

Error:
odbc 驅動程式管理員 找不到資料來源名稱且未指定預設的驅動程式


Cause:
沒有設定Database。並不是驅動程式問題。

Solution:
SQL Server Native Client 11.0 ODBC Driver connection strings

Driver=SQL Server;Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;





2020年6月15日 星期一

outlook 開啟附檔 沒有回應

Reference:
「Outlook not responding」錯誤或在開啟檔案或傳送電子郵件時 Outlook 發生凍結

狀況:
Outlook 開啟附檔時,顯示 沒有回應,卡住幾分鐘後附檔才打開。

解法:
調整 Outlook 增益集。
感覺卡住像是在檢查病毒,所以先把防毒的 Add-on 關閉測試,一猜就中!
重開 Outlook 再測試附檔已經不會卡住了。


HTC Desire 12S 沒聲音

這一陣子常漏接訊息,發現是手機會變成收到訊息或來電沒聲音。

送修手機很麻煩,找到網路上的解法:
插耳機,等手機出現耳機符號在拔除,就會恢復。

試過這方法的確有效,但是要隨身攜帶耳機很麻煩。

找到另一方法:
在 LINE 開一個自己一人的群組,沒聲音時進群組開通話,退出後就有聲音了。

2020年6月14日 星期日

Linux ntpdate 手動更新系統時間

ntpdate <timeserver>
hwclock -w

CentOS 7 開機自動執行

Reference:
解決 CentOS 7 開機不啟動 rc.local
設定 CentOS 7 開機時自動執行重啟網卡指令

systemctl enable rc-local.service
systemctl start rc-local.service
systemctl status rc-local.service

chmod +x /etc/rc.d/rc.local

將要開機自動執行的指令寫在 /etc/rc.d/rc.local

Solaris 9 修改 IP, Hostname

Reference:
How to change hostname in Solaris 8, 9 and 10

edit files:
/etc/hosts
/etc/nodename
/etc/hostname.<nic card>    Ex: hostname.le0

2020年6月6日 星期六

Redhat 3 轉虛擬機

Reference:
Solved: Linux Red Hat P2V problem. Cannot boot after conversion. Solution below in attachment
轉載(Centos Linux Rescue 修復方式)
Virtual machine does not boot after being converted from a physical Red Hat machine (1002402)

原作者的圖文操作步驟

Linux Red Hat 3 Physical To Virtual Conversion – Vmware

1. On the machine you will be performing the conversion open VMware vCenter Converter Standalone Client.
After several attempts with various versions, my preference for P2Ving old Linux servers is 4.0.1


2. Specify the source machine to be virtualized. Add the IP and account credentials ensuring you select Linux.

3. Add the IP address, username and password of the ESX host your physical server will be virtualized to.

4. Choose the name and the Datastore as required.


5. Here you can modify disk settings, quantity of CPU’s, network cards, advanced options and most importantly, the VMware Helper Settings.
After playing around with the disk settings, I saved over 80GB by reducing the size of the disks to a more reasonable level. Also don’t worry about the conversion time. It’ll be much quicker than shown here.

6. Add a helper on the same vlan as the VM will reside. I don’t use auto as I can’t get it to work.

7. Time to read through the summary of your settings for the conversion then select ‘Finish’.

8. The job then moves into the ‘Running’ state


9. Open the vSphere Client, navigate to the vDatacenter the ESX host you selected reside in and open the ‘Console’ of the VM. You can see the creation process up to a certain point. Important if it is going to fail to know where about in the process.
10. Once it has completed the P2V process, open the ‘Edit Settings’ choice.

Go to ‘Boot Options’ and choose to enter the ‘BIOS Settings’ on start up. You may choose to disable networking (under the Hardware tab) temporarily. Advisable if this VM is to be the physical server’s replacement with same IP even though in ‘Linux Rescue’ it asks if you want to enable networking I don’t want any conflicts with the physical production server that is still running.

11. Power on the VM

12. The VM will boot into Bios. Change the boot settings from below to have ‘CD-Rom Drive’ above ‘Hard Drive’
This will allow you to boot to the OS ISO to start the ‘Linux Rescue’ process.

13. Choose the ‘Exit’ tab and ‘Exit Saving Settings’

14. Choose the CD\DVD Drive option and connect to the location of your Linux OS ISO\Disk. I prefer to make an ISO of the physical disk and add it to a Datastore.


15. Highlight the OS and click ‘OK’

16. Once at the initial screen type ‘linux rescue’ and press enter.

17. As stated earlier, I choose ‘No network connection’. I don’t want a conflict with the running physical server. It is not needed to get the server working as a VM.

18. Choose ‘Continue’

19. Once it is finished you will see the below message, just select ‘OK’.

20. You can now mount the image with the following command. "chroot /mnt/sysimage"

21. Run ‘kudzu’ to scan for hardware changes and remove old hardware.



You will want to ‘remove configuration’ for all the old physical devices.

22. Now you will have obtained access to the command line.
Time to check the name and version of your Linux OS.
View the contents of /lib/modules as below then run the following command to rebuild the ramdisk installer:
Mkinitrd –v –f initrdxxxx.img xxxx
i.e. I used the following: mkinitrd –v –f initrd2.4.9-e.34smp.img 2.4.9-e.34smp



23. Once complete you will need to view/edit your grub.conf.
I made a copy of the original and left it in the /boot/grub folder prior to modifying it.

24. On the four servers I have successfully converted the same occurred on all of them.
All the entries in the grub.conf were (hd0,2) whereas they needed to be changed to (hd0,1) which I did in VI.


25. Save the modified file and shutdown the VM.
Disconnect the Linux ISO from the VM and restart the VM.
If you have been successful, you’ll see the following screen. I booted 3rd one down successfully.

26. After the server goes through its initialisation phase you will be taken to the normal command prompt.

27. Login as per normal. You may need to make some changes to the system or have a DBA/Apps guy ensure any of their installed components are working correctly. Apart from that, you’re done! Congratulations 

2020年5月26日 星期二

生活紀錄 (痛風、閃到腰)

這一陣子狀況不太好。

2020/5/17(日) 參加竹北 YY Sports 10K 跑步完沒異狀,下午覺得左腳掌不對勁,感覺痛風快來了。
吃痛風丸沒閃過,幸好沒有很嚴重,不會太痛。
連續吃了四天藥 (早上痛風丸、中午晚上秋水仙素),剛好這一星期都下雨,休息了一星期。

2020/5/24(日) 參加竹北 YY Sports 10K 跑步完沒異狀,下午到公司加班,蹲下時突然閃到腰,晚上睡覺時超難受,翻身痛到受不了。
2020/5/25(一)早上翻出以前的藥 (止痛藥、肌肉鬆弛劑),吃了一份去上班,到晚上感覺幾乎好了。但是,感覺左腳掌又不對勁了,吃痛風丸沒閃過。
連續吃了四天藥 (早上痛風丸、中午晚上秋水仙素),2020/5/28(四)晚上可以跑步了

反省:
這一陣子工作太累,飲食又沒節制,是身體在提醒我該注意了。

2020年5月23日 星期六

Redhat 6 disable registration alert

yum remove subscription*

Redhat / CentOS 6 "Authentication is required"

狀況:
使用 VNC 遠端登入,不斷彈出對話框 Authentication is required to set the network proxy used for downloading packages

解法:
# which gpk-update-icon
/usr/bin/gpk-update-icon
# rpm -qf /usr/bin/gpk-update-icon
gnome-packagekit-2.28.3-3.el6.x86_64
# rpm -e gnome-packagekit-2.28.3-3.el6.x86_64


2020年5月21日 星期四

Redhat 6 Xwindow fonts

狀況:
從 Solaris 把 Xwindow DISPLAY 到 Redhat,顯示的字變大,造成內容被擠壓

原因:
一開始猜測是解析度,調高後還是顯示異常。
因為Redhat 6 安裝成 Desktop,預設安裝了字型為100dpi,缺少75dpi字型

[root@redhat6 ~]# rpm -qa|grep xorg|grep font
xorg-x11-fonts-misc-7.2-11.el6.noarch
xorg-x11-fonts-ISO8859-1-100dpi-7.2-11.el6.noarch
xorg-x11-fonts-100dpi-7.2-11.el6.noarch
xorg-x11-fonts-Type1-7.2-11.el6.noarch
xorg-x11-font-utils-7.2-11.el6.x86_64

解法:
補安裝75dpi字型後DISPLAY正常。

[root@redhat6 ~]# rpm -qa|grep xorg|grep font
xorg-x11-fonts-ISO8859-14-75dpi-7.2-11.el6.noarch
xorg-x11-fonts-ISO8859-9-75dpi-7.2-11.el6.noarch
xorg-x11-fonts-misc-7.2-11.el6.noarch
xorg-x11-fonts-75dpi-7.2-11.el6.noarch
xorg-x11-fonts-ISO8859-2-75dpi-7.2-11.el6.noarch
xorg-x11-fonts-ISO8859-15-75dpi-7.2-11.el6.noarch
xorg-x11-fonts-ISO8859-1-100dpi-7.2-11.el6.noarch
xorg-x11-fonts-100dpi-7.2-11.el6.noarch
xorg-x11-fonts-Type1-7.2-11.el6.noarch
xorg-x11-fonts-ISO8859-1-75dpi-7.2-11.el6.noarch
xorg-x11-font-utils-7.2-11.el6.x86_64

2020年5月20日 星期三

Redhat 6 allow remote DISPLAY to console

Reference:
CentOS 開啟 XDMCP
Centos 6 如何啟 XDMCP?
  • yum -y install gdm
  • vi /etc/gdm/custom.conf
# GDM configuration storage

[daemon]

[security]
DisallowTCP=false
AllowRemoteRoot=true

[xdmcp]
Enable=true

[greeter]

[chooser]

[debug]
  • 關閉iptables
  • yum -y install gdm  
  • yum -y groupinstall "X Window System"
  • yum -y groupinstall "Desktop"
  • reboot
  • 確定XDMCP 177 port 服務有正確啓動
netstat -tulnp |grep 177

udp 0 0 0.0.0.0:177 0.0.0.0:* 1651/gdm-binary

2020年5月18日 星期一

用 VNC 連 Linux console

需求:
用 VNC 連到 Linux Console

作法:

  1. 安裝 TigerVNC Server
  2. 執行 vncpasswd 創建密碼
  3. 執行 x0vncserver -display :0 -passwordfile ~/.vnc/passwd
  4. 用 vncview 連到 linux


2020年5月2日 星期六

Reference:
如何處理Windows虛擬機ping包顯示Destination host unreachable

夜路走多了總是會遇到鬼.....
ㄟ.... 不是啦,應該是工作久了就會遇到比較多奇怪的狀況。

狀況:
Windows server 2003虛擬機當機重開,開機很久才完成(大約10分鐘)。
開機後網路不通,檢查網路設定正常,也有收送封包,但無法ping通。
搞了好久,最後同事在Event Log看到錯誤訊息(如下)。

IPSec 驅動程式已經進入區塊模式。IPSec 將捨棄開機時 IPSec 豁免原則不允許的所有輸入或輸出 TCP/IP 網路流量。 使用者動作: 若要復原到完全無安全性的 TCP/IP 連結,請停用 IPSec 服務,然後重新啟動電腦。 請檢視安全性事件日誌中的事件,以取得更多疑難排解的詳細資訊。

解法請參考這一篇。

找一台正常的Windows 2003 匯出 registry,再把 registry 匯入有問題的 Windows 2003 後恢復。
[HKEY_LOCAL_MACHINE\SOFTWARE\Policies\Microsoft\windows\IPSec]


2020年4月25日 星期六

更換椅子坐墊 DIY

椅子坐墊的皮面裂開了,參考 【居家DIY】(IKEA布料)椅墊大變身&全身鏡布罩 自己更換皮面。

在蝦皮購物買的皮面布料今天到貨,就來更換吧。

(更換前)

2020 ZEPRO RUN 鞋子到囉

2020 年的 ZEPRO RUN 原本預定在 3/29,但因為新冠病毒延期到 6/14。
收到寄來的鞋子了。

2020年4月14日 星期二

ssh from Windows to Linux

Reference:
在 Win7 上安装 OpenSSH
PowerShell/Win32-OpenSSH
SSH login without password
Windows SSH: Permissions for 'private-key' are too open

目的:
從Windows用ssh免密碼登入Linux

作法:
1. download Win32-OpenSSH,解壓縮即可
2. 執行 ssh-keygen 產生一對金鑰,預設放在 C:\Users\帳號\.ssh
3. 將 C:\Users\帳號\.ssh\id_rsa.pub 權限修改為只有自己,參考這一篇
4. 登入 Linux,產生 ~/.ssh/authorized_keys,內容貼上 C:\Users\帳號\.ssh\id_rsa.pub
5. chmod 600 ~/.ssh/authorized_keys
6. ssh -l account linux-machine [command]

2020/4/16 update:
Win32-OpenSSH 有一個 bug,它執行後必須多按一次 Enter,這樣造成 batch file 卡住。
改安裝 cygwin 的 openssh,測試 OK。

cygwin 預設沒有安裝 openssh,必須另外勾選。

安裝之後必須修改 C:\cygwin64\etc\nsswitch.conf
db_home:  /cygdrive/c/Users/%U
否則會有錯誤訊息:Could not create directory '/home/[Account]/.ssh'


2020年4月13日 星期一

Outlook附件禁止收取

Reference:
解決Outlook 禁止存取下列可能不安全的附件,更新檔作祟!

錯誤訊息:
Outlook禁止存取下列可能不安全的附件。

解法:
移除更新檔
Outlook 2007 (KB3191898)
Outlook 2010 (KB3203467)
Outlook 2013 (KB3191938)
Outlook 2016 (KB3191932)

SSH Hostkeyverification failed

Reference:
ssh连接不成功解决办法

錯誤訊息:
WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!

可能的原因:
多台機器用同一個FQDN做load balance。

解法:
1. 編輯 ~/.ssh/known_hosts,刪除那一筆FQDN
2. 編輯 .ssh/config (或者/etc/ssh/ssh_config),加入 StrictHostKeyChecking no

2020年3月28日 星期六

虛擬延伸桌面軟體 (無限大的桌面)

狀況:
我的筆電螢幕解析度只有1366x768,有一個軟體的視窗高度超過768,它又沒設計捲軸,下面的 "確定" 按鈕點不到....

解法:
找到 Infinite Screen 可以做虛擬延伸桌面。
http://ynea.futureware.at/cgi-bin/infinite_screen.pl

操作方法:
執行 Infinite Screen 程式後,按住鍵盤左邊的 Ctrl+Shift,移動滑鼠會變成有無限的桌面。
這軟體太酷了!

2020年3月22日 星期日

更新 powershell 版本

檢查 powershell 版本指令:get-host

更新 powershell 要安裝 WMF
安裝與設定 WMF 5.1

2020年3月18日 星期三

2020年3月15日 星期日

2020/3/15 Tomo 頭前溪 無緣補償馬

今年因為 新冠狀病毒 取消了多場馬拉松賽事。
新竹市馬拉松也取消了,我本來計畫在這一場跑初馬....

在 Facebook 看到 #日本人跑遍台灣 Tomo 辦了這個免費活動就參加了。


2020年2月28日 星期五

Windows 10 檔名、目錄 區分大小寫

Reference:
wind10 檔名區分大小寫

讓Windows 10 檔名、目錄可以區分大小寫
作法:

  1. Windows 10 版本必須 1803 以上
  2. 用系統管理員身分執行PowerShell
  3. 執行 Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux (安裝 Linux 子系統)
  4. 執行 fsutil.exe file setCaseSensitiveInfo D:\Study enable (在D:\Study啟用 區分大小寫)
PS. 只支援Windows 10 自己的 NTFS 硬碟,不支援網路磁碟機


2020年2月11日 星期二

Visual Studio 2003 deploy to client (合併模組 Merge Modules)

Reference:
介紹 Windows Installer 好用的合併模組 (Merge Modules)
Crystal Reports and Visual Studio .NET 
Crystal report load failed..?
1426232 - File not found error experienced after deploying application.
Regedit.exe import fails to pick up “text” field

緣由:
用 VS2003 開發的 Crystal report 給 User 使用,但不想在 User PC 安裝 VS2003。

方法:
Merge Modules 的方式 把 Crystal report 需要的檔案包成 msi 安裝檔,讓 User 執行安裝程式。

VS2003 Crystal report 需要的 Merge Modules:
Crystal_Database_Access2003.msm
Crystal_Database_Access2003_enu.msm
Crystal_Managed2003.msm
Crystal_regwiz2003.msm
VC_User_CRT71_RTL_X86_---.msm (used for reports based on ADO.NET)
VC_User_STL71_RTL_X86_---.msm (used for reports based on ADO.NET)

User 安裝後執行有錯誤訊息:
Cannot find KeycodeV2.dll, or invalid keycode.
Load report failed.


原因:
在封裝時輸入 Crystal report license key ,但無法裝到 User PC。

解法:
從開發者的電腦匯出 registry key,在 User PC 匯入。
但不能用 regedit 來做,因為 registry key 的內容有換行 (new line),匯入會失敗。
必須改用 reg export, save, import, restore。

步驟:
開發者電腦
reg export "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Crystal Decisions\Crystal Reports\VSNET\Keycodes\CR9 NET" key.reg
reg save "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Crystal Decisions\Crystal Reports\VSNET\Keycodes\CR9 NET" key.bin

User PC 用系統管理員權限開 cmd 執行
reg import key.reg
reg restore "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Crystal Decisions\Crystal Reports\VSNET\Keycodes\CR9 NET" key.bin

2020年2月3日 星期一

Linux檔案和目錄限制

Reference:
Linux檔案和目錄限制

ext3檔案系統的一級子目錄的個數預設為32000個,ext4取消了這一限制

2020年1月16日 星期四

Graylog 安裝及設定

Graylog 是收集 log 的工具,可以將 Windows, Linux log 傳到同一台(組) Graylog。

安裝:
Installing Graylog

可以直接下載 VM ova image,匯入後改為固定 IP address 即可。

edit /etc/netplan/01-netcfg.yaml
network:
  version: 2
  renderer: networkd
  ethernets:
    enp0s3:
      dhcp4: yes
    ens160:
            addresses: [192.168.10.2/24]
            gateway4: 192.168.10.254
            nameservers:
                    search: [my.domain]
                    addresses: [192.168.10.1]

重開機或 執行 sudo netplan apply 讓 IP 生效。

修改時區
edit /etc/graylog/server/server.conf
root_timezone = Asia/Taipei

修改網頁密碼
執行 echo -n "Enter Password: " && head -1 </dev/stdin | tr -d '\n' | sha256sum | cut -d" " -f1
把結果貼到 /etc/graylog/server/server.conf 的 root_password_sha2

重開機或 執行 sudo systemctl start graylog-server.service 後生效

2020年1月1日 星期三

Linux / Unix audit log

Linux audit log啟用方法:
1. 在 /etc/audit/audit.rules 加上 -w <目錄>
2. service auditd restart
3. log檔在 /var/log/audit/audit.log

測試CentOS 6.10有效。

Reference:
[Centos7] audit 服務
linux 的 audit 服務


Solaris audit log: (實測 Solaris 10)
1. 啟用:
# init 1            (進入single user mode)
#/etc/security/bsmconv        (啟用audit,若要關閉 audit 指令為 bsmunconv)
# reboot            (重開機生效)

2. 要修改的檔案
/etc/security/audit_control      (要記錄哪些東西,預設只有 lo: login or logout)
/etc/security/audit_user      (要記錄哪些 user,預設只有 root)

3. audit_control 的參數功能請參照
/etc/security/audit_class

4. 修改後下指令 audit -s 才會生效

Reference:
在solaris上布署审计功能
How to Enable the Audit Service