2022年1月12日 星期三

AWS lightsail Login failed. CLIENT_UNAUTHORIZED [769]

Misconfiguration of the Lightsail system key /etc/ssh/lightsail_instance_ca.pub

Lightsail uses the system key /etc/ssh/lightsail_instance_ca.pub to activate browser-based SSH access. If this file is missing, then SSH authentication fails and you receive the CLIENT_UNAUTHORIZED [769]error. The same error occurs when the Lightsail system key isn't specified in the TrustedUserCAKeys parameter in the SSH configuration file /etc/ssh/sshd_config.

If the SSH connection to the instance through the terminal or PuTTY application works, then log in to the instance and confirm that the /etc/ssh/sshd_config file exists and that it contains the ssh-rsa key.

If the file is missing, then recreate the file using the following steps:

1.    Run the following command and confirm that you get the ssh-rsa key in the command output:

sudo cat /var/lib/cloud/instance/user-data.txt | grep ^ssh-rsa

2.    If the command returns the ssh-rsa key in the output, then run the following commands to copy it to /etc/ssh/lightsail_instance_ca.pub:

sudo sh -c "cat /var/lib/cloud/instance/user-data.txt | grep ^ssh-rsa > /etc/ssh/lightsail_instance_ca.pub"
    sudo sh -c "echo >> /etc/ssh/sshd_config" 
    sudo sh -c "echo 'TrustedUserCAKeys /etc/ssh/lightsail_instance_ca.pub' >> /etc/ssh/sshd_config"
    sudo systemctl restart sshd

3.    If you don't get an ssh-rsa key from step 1, or if you can't SSH to the instance using the terminal or PuTTY application, then create a manual snapshot of the instance and launch a new instance with that snapshot. The Lightsail system key is added to the server automatically at instance launch.


 Resolve Lightsail browser-based SSH console errors (amazon.com)

2017年1月23日 星期一

重設 (Reset) MYSQL root 密碼 (Password)

1. Stop MySQL

/etc/init.d/mysql stop

2. 入Safe mode


mysqld_safe --skip-grant-tables &

3.改密碼 (Password)
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD("password") WHERE User='root';
mysql> flush privileges;
mysql> quit
 
4. 重啟 MySQL
 
/etc/init.d/mysql start
 
5. 登入 MySQL 
 
mysql -u root -p
 
 
 
 

2017年1月16日 星期一

如何用TCPDF列印出剔號 (Tick)

// 設定用zapfdingbats字型
$pdf->SetFont('zapfdingbats', '', 14);

//  剔號 (Tick) = Chr(52)
$pdf->Cell(10, 10, chr(52), 1, 'C', 0, 0, '', '', true);

參考: TCPDF example 55
https://tcpdf.org/examples/example_055/

2016年9月28日 星期三

Set Time-zone to Hong Kong

sudo timedatectl set-timezone Asia/Hong_Kong
 

2015年3月12日 星期四

Microsoft Critical Patch KB3002657 Cause NAS logon problem:

UN-Installation from Windows 2003 Server

* Go into Control Panel, Add or Remove Programs. Make sure "Show updates" is checked. Then click on the update and click Remove "KB3002657"

* After uninstall, users are able to logon and see their drive/directory.

2015年3月6日 星期五

Add User Data for Testing using seeding (Lavarel 5)

1)  Edit "DatabaseSeeder.php" under  database/seeds in the project directory.

2) Uncomment the following line:

$this->call('UserTableSeeder');

3) Add the following block of code:

use App\User;

class UserTableSeeder extends Seeder {

    public function run()
    {
        DB::table('users')->delete();

        User::create(array(
                'name' => 'admin',
                'email' => 'admin@test.com',
                'password' => Hash::make('password')
            ));
    }
}


4)  Run the following command to add data to the user table.

 php artisan db:seed 

2015年3月5日 星期四

Error Message when running PHP artisan migrate after installation

Command: php artisan migrate
 
 [PDOException]
 SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

If you are not using Lavarel homestead, you have to change the setting in .env file in the project directory.

Orginal
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

Example for XAMPP/WAMP
DB_HOST=localhost
DB_DATABASE=myDB
DB_USERNAME=root
DB_PASSWORD=

* I create a database call myDB (using root with no password)