2017年12月18日 星期一

C++ Pass by Pointer vs Pass by value vs Pass by Reference

#include <iostream>
#include <time.h>

void function1(int *ptr) { // pass by pointer
*ptr *= 5;
}

void function2(int val) { // pass by value
val *= 5;
}

void function3(int& ref) { // pass by reference
ref *= 5;
}

int main() {
int nmbr = 5;
clock_t start = clock();
for (long i = 0; i < 1000 * 1000 * 1000; ++i) {
function1(&nmbr);
//function2(nmbr);
//function3(nmbr);
}
clock_t stop = clock();
std::cout << "time: " << stop - start;
return 0;
}

2017年9月18日 星期一

rdesktop on CentOS 6.9

On Windows Mobaxterm, ssh to CentOS 6.9, make sure xclock run well

rdesktop
sudo yum install -y rdesktop
sudo apt-get install -y rdesktop
rdesktop 192.168.31.2
rdesktop 192.168.31.2 -A "%ProgramFiles%\ThinLinc\WTSTools\seamlessrdpshell.exe"
rdesktop -u "leungric" -g 1300x700 192.168.31.2
rdesktop -u "leungric" -f 192.168.31.2
rdesktop -u "leungric" -A -s seamlessrdpshell.exe notepad.exe 192.168.31.2

I failed to install the server!


rdesktop -A -s "%ProgramFiles%\ThinLinc\WTSTools\seamlessrdpshell.exe %ProgramFiles%\Internet Explorer\iexplore.exe" localhost:3389 -u administrator -p password
rdesktop -A -s "%ProgramFiles%\ThinLinc\WTSTools\seamlessrdpshell.exe %ProgramFiles%\Internet Explorer\iexplore.exe" 192.168.31.2:3389

rdesktop -A -s "%ProgramFiles%\ThinLinc\WTSTools\seamlessrdpshell.exe %ProgramFiles%\Internet Explorer\iexplore.exe" 192.168.31.2:3389
On Windows, Individual use and small groups, email download link, tl-4.8.0-server.zip
C:\Users\leungric\Downloads\tl-4.8.0-server\windows-tools\wts-tools\tl-wts-tools.exe


On LInux, i dont know
sudo yum install -y unzip
unzip tl-4.8.0-server.zip
sudo yum install -y pygtk2
cd tl-4.8.0-server
sudo ./install-server


2017年9月13日 星期三

Guacamole and Jetty 9 with HTTPS on Raspbian 9 on Raspberry Pi 3B

ref
https://www.raspberrypi.org/forums/viewtopic.php?f=81&t=71166

Configureation UI
enable ssh, vnc on menu "raspberry pi configuration"
Wifi country select GB

create account
ssh pi@192.168.1.3 with raspberry
sudo userdel -r leungric
sudo adduser leungric
sudo nano /etc/sudoers # or sudo visudo
# add line to bottom, must be after $sudo line
leungric ALL=(ALL:ALL) NOPASSWD:ALL
ssh leungric@192.168.1.3
sudo ls -al /root

update if have not yet
sudo apt-get update

real-vnc-server is the builtin one
sudo apt-get install realvnc-vnc-server
sudo adduser leungric sudo
sudo vncpasswd -service
enter pw
# pw set in /root/.vnc/config.d/vncserver-x11
sudo nano /root/.vnc/config.d/vncserver-x11
Authentication=VncAuth
Encryption=AlwaysOff
Password=e0fd0472492935da  # foobar
# now Windows TightVncViewer can use password only to vnc raspberry pi


Wifi
sudo raspi-config

Versions
cat /etc/*release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"

should be optional
sudo apt-get dist-upgrade

xrdp
sudo apt-get install -y xrdp

java
sudo apt-get install oracle-java8-jdk
export JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt
printenv | grep JAVA
JAVA_HOME=/usr/lib/jvm/jdk-8-oracle-arm32-vfp-hflt
java -version
java version "1.8.0_65"
Java(TM) SE Runtime Environment (build 1.8.0_65-b17)
Java HotSpot(TM) Client VM (build 25.65-b01, mixed mode)

listen before jetty
sudo netstat -natup
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:5900            0.0.0.0:*               LISTEN      1109/vncserver-x11-
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1087/sshd
tcp        0      0 192.168.1.3:22          192.168.1.197:49388     ESTABLISHED 1417/sshd: leungric
tcp        0      0 127.0.0.1:53516         127.0.0.1:39569         ESTABLISHED 1109/vncserver-x11-
tcp        0      0 127.0.0.1:39569         127.0.0.1:53516         ESTABLISHED 1133/vncserverui
tcp6       0      0 :::5900                 :::*                    LISTEN      1109/vncserver-x11-
tcp6       0      0 ::1:3350                :::*                    LISTEN      1934/xrdp-sesman
tcp6       0      0 :::22                   :::*                    LISTEN      1087/sshd
tcp6       0      0 :::3389                 :::*                    LISTEN      1946/xrdp
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           389/avahi-daemon: r
udp        0      0 0.0.0.0:36630           0.0.0.0:*                           389/avahi-daemon: r
udp        0      0 0.0.0.0:68              0.0.0.0:*                           437/dhcpcd
udp6       0      0 :::5353                 :::*                                389/avahi-daemon: r
udp6       0      0 :::42503                :::*                                389/avahi-daemon: r
  

     

jetty9
sudo apt-get update
sudo apt-get -y upgrade
sudo apt-cache search jetty
sudo apt-get -y install jetty9
sudo nano /etc/default/jetty9
NO_START=0 (make sure)
sudo service jetty9 restart
sudo service jetty9 status
http://192.168.1.3:8080

port after jetty restarted
sudo netstat -natup
Proto Local Address           Foreign Address         State      
tcp   0.0.0.0:5900            0.0.0.0:*               LISTEN     
tcp   0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp   127.0.0.1:6010          0.0.0.0:*               LISTEN     
tcp   127.0.0.1:41864         127.0.0.1:35063         ESTABLISHED
tcp   192.168.31.3:22         192.168.31.4:53842      ESTABLISHED
tcp   192.168.31.3:22         192.168.31.4:53843      ESTABLISHED
tcp   127.0.0.1:35063         127.0.0.1:41864         ESTABLISHED
tcp6  :::5900                 :::*                    LISTEN     
tcp6  :::8080                 :::*                    LISTEN     
tcp6  :::22                   :::*                    LISTEN     
tcp6  ::1:6010                :::*                    LISTEN     
tcp6  ::1:43222               ::1:6010                TIME_WAIT  
udp   0.0.0.0:5353            0.0.0.0:*                          
udp   0.0.0.0:60726           0.0.0.0:*                          
udp   0.0.0.0:68              0.0.0.0:*                          
udp6  :::5353                 :::*                               
udp6  :::42955                :::*                               

port after browsed
Send-Q Local Address           Foreign Address         State       
     0 0.0.0.0:5900            0.0.0.0:*               LISTEN      
     0 0.0.0.0:22              0.0.0.0:*               LISTEN      
     0 127.0.0.1:6010          0.0.0.0:*               LISTEN      
     0 127.0.0.1:41864         127.0.0.1:35063         ESTABLISHED 
   108 192.168.31.3:22         192.168.31.4:53842      ESTABLISHED 
     0 192.168.31.3:22         192.168.31.4:53843      ESTABLISHED 
     0 127.0.0.1:35063         127.0.0.1:41864         ESTABLISHED 
     0 :::5900                 :::*                    LISTEN      
     0 :::8080                 :::*                    LISTEN      
     0 :::22                   :::*                    LISTEN      
     0 ::1:6010                :::*                    LISTEN      
     0 192.168.31.3:8080       192.168.31.4:53863      ESTABLISHED 
     0 192.168.31.3:8080       192.168.31.4:53864      ESTABLISHED 
     0 192.168.31.3:8080       192.168.31.4:53865      ESTABLISHED 
     0 192.168.31.3:8080       192.168.31.4:53866      ESTABLISHED 
     0 0.0.0.0:5353            0.0.0.0:*                           
     0 0.0.0.0:60726           0.0.0.0:*                           
     0 0.0.0.0:68              0.0.0.0:*                           
     0 :::5353                 :::*                                
     0 :::42955                :::*                                

basic packages
sudo apt-get install -y
libjpeg62-turbo-dev
libcairo2-dev
libossp-uuid-dev
libjpeg is required for writing jpeg messages
Cairo is required for drawing instructions
The OSSP UUID library is required

then required packages
sudo apt-get install -y
gawk
libssl-dev
libogg-dev
libvorbis-dev
libpulse-dev
libfreerdp-dev
libwebp-dev
libpango1.0-dev
libavcodec-dev
libavutil-dev
libswscale-dev
libtelnet-dev
libvncserver-dev

finally required packages
sudo apt-get install -y
libssh-dev
libssh2-1-dev

Recheck for below
./configure --with-init-dir=/etc/init.d
checking for gawk... gawk
Unable to find libssl.
Unable to find libogg / libvorbis / libvorbisenc
Unable to find libpulse
Unable to find libfreerdp-core / libfreerdp
Unable to find libwebp
libssl .............. yes
libvorbis ........... yes
libpulse ............ yes
freerdp ............. yes
libwebp ............. yes
pango ............... yes
libavcodec .......... yes
libavutil ........... yes
libswscale .......... yes
libVNCServer ........ yes
SSH ....... yes
Telnet .... yes
VNC ....... yes

Debian 11 2022 (not Debian 9 2018, not work in Debian 11 2022)
# sudo apt-get install libfreerdp-dev
sudo apt-get install freerdp2-dev

prohibit packages
sudo apt-get install -y
libpng12-dev (this will remove cairo and cause failure)


configure server (0.9.13 working in 2021)
guacamole-server-0.9.13-incubating.tar.gz
wget --user-agent=Mozilla \ -e robots=off "https://archive.apache.org/dist/guacamole/0.9.13-incubating/source/guacamole-server-0.9.13-incubating.tar.gz" -O guacamole-server-0.9.13-incubating.tar.gz
tar -xzf guacamole-server-0.9.13-incubating.tar.gz
cd guacamole-server-0.9.13-incubating
./configure --with-init-dir=/etc/init.d

configure server (1.0.0 yes work in Debian 9 Stretch in 2022)
wget --user-agent=Mozilla \ -e robots=off "https://apache.org/dyn/closer.cgi?action=download&filename=guacamole/1.0.0/source/guacamole-server-1.0.0.tar.gz" -O guacamole-server-1.0.0.tar.gz
tar -xzf guacamole-server-1.0.0.tar.gz
cd guacamole-server-1.0.0
./configure --with-init-dir=/etc/init.d

configure server (1.4.0 not work in Debian 11 2022)
sudo apt-get install -y libwebsockets-dev libavcodec-dev libavformat-dev libavutil-dev libswsccale-dev
wget --user-agent=Mozilla \ -e robots=off "https://apache.org/dyn/closer.lua/guacamole/1.4.0/source/guacamole-server-1.4.0.tar.gz?action=download" -O guacamole-server-1.4.0.tar.gz
tar -xzf guacamole-server-1.4.0.tar.gz
cd guacamole-server-1.4.0
./configure --with-init-dir=/etc/init.d



guacamole-server version 0.9.13
guacamole-server version 0.9.13-incubating
   Library status:
     freerdp ............. yes
     pango ............... yes
     libavcodec .......... yes
     libavutil ........... yes
     libssh2 ............. yes
     libssl .............. yes
     libswscale .......... yes
     libtelnet ........... yes
     libVNCServer ........ yes
     libvorbis ........... yes
     libpulse ............ yes
     libwebp ............. yes
   Protocol support:
      RDP ....... yes
      SSH ....... yes
      Telnet .... yes
      VNC ....... yes
   Services / tools:
      guacd ...... yes
      guacenc .... yes
   Init scripts: /etc/init.d
Type "make" to compile guacamole-server.

Leaving theses nos

Line 16: checking whether we are cross compiling... no
Line 20: checking for gcc option to accept ISO C89... none needed
Line 38: checking for dlltool... no
Line 45: checking for sysroot... no
Line 49: checking if mt is a manifest tool... no
Line 63: checking if gcc supports -fno-rtti -fno-exceptions... no
Line 70: checking whether -lc should be explicitly linked in... no
Line 73: checking for shl_load... no
Line 74: checking for shl_load in -ldld... no
Line 75: checking for dlopen... no
Line 78: checking whether a statically linked program can dlopen itself... no
Line 89: checking for gcc option to accept ISO C99... none needed
Line 111: checking pngstruct.h usability... no
Line 112: checking pngstruct.h presence... no
Line 113: checking for pngstruct.h... no
Line 124: checking for CU_run_test in -lcunit... no
Line 125: checking for main in -lwsock32... no
Line 146: checking whether DSA_SIG_get0 is declared... no
Line 147: checking whether DSA_get0_pqg is declared... no
Line 148: checking whether DSA_get0_key is declared... no
Line 149: checking whether RSA_get0_key is declared... no
Line 169: checking whether freerdp_convert_gdi_order_color is declared... no
Line 170: checking whether freerdp_color_convert_drawing_order_color_to_gdi_color is declared... no
Line 171: checking for rdpSvcPlugin.interval_ms... no
Line 183: checking for rdpSettings.SupportDisplayControl... no
Line 197: checking for rdpSettings.Width... no
Line 198: checking for rdpSettings.Height... no
Line 203: checking for CHANNEL_ENTRY_POINTS_FREERDP... no
Line 208: checking whether IWTSVirtualChannelCallback.OnDataReceived() uses a wStream... no
Line 209: checking whether interleaved_decompress() accepts an additional palette parameter... no
Line 210: checking whether planar_decompress() can flip... no
Line 211: checking for rdpContext.codecs... no
Line 217: checking for gcry_control in -lssh2... no

guacamole-server version 1.4.0 (may work in Debian 11 2022)
------------------------------------------------
guacamole-server version 1.4.0
------------------------------------------------

   Library status:

     freerdp2 ............ yes
     pango ............... yes
     libavcodec .......... yes
     libavformat.......... yes
     libavutil ........... yes
     libssh2 ............. yes
     libssl .............. yes
     libswscale .......... yes
     libtelnet ........... yes
     libVNCServer ........ yes
     libvorbis ........... yes
     libpulse ............ yes
     libwebsockets ....... yes
     libwebp ............. yes
     wsock32 ............. no

   Protocol support:

      Kubernetes .... yes
      RDP ........... yes
      SSH ........... yes
      Telnet ........ yes
      VNC ........... yes

   Services / tools:

      guacd ...... yes
      guacenc .... yes
      guaclog .... yes

   FreeRDP plugins: /usr/lib/arm-linux-gnueabihf/freerdp2
   Init scripts: /etc/init.d
   Systemd units: no

Type "make" to compile guacamole-server.


install server
make
sudo make install
sudo ldconfig
sudo update-rc.d guacd defaults
sudo /etc/init.d/guacd restart
sudo /etc/init.d/guacd status
guacd is running with PID=27937.
sudo service guacd status
ps -ef | grep guacd
root     27937     1  0 02:25 ?        00:00:00 /usr/local/sbin/guacd -p /var/run/guacd.pid
leungric 27952   912  0 02:25 pts/0    00:00:00 grep --color=auto guacd
# sudo systemctl status guacd  # Active: inactive (dead) # no need to use systemctl

Maven
sudo apt-get install -y maven

install client war ( 0.9.13 debian 9 2018)
wget --user-agent=Mozilla \ -e robots=off "https://archive.apache.org/dist/guacamole/0.9.13-incubating/source/guacamole-client-0.9.13-incubating.tar.gz" -O guacamole-client-0.9.13-incubating.tar.gz
tar -xzf guacamole-client-0.9.13-incubating.tar.gz
cd guacamole-client-0.9.13-incubating/
mvn package (very long time on 1.2GHz Quad Core, take a break, 15-30mins)
cd guacamole/target/
ls guacamole-0.9.13-incubating.war
sudo mv guacamole-0.9.13-incubating.war /usr/share/jetty9/webapps/guacamole.war
sudo service jetty9 restart
http://192.168.1.3:8080/guacamole

install client war (1.0.0 yes work in debian 9 2022)
wget --user-agent=Mozilla \ -e robots=off "https://archive.apache.org/dist/guacamole/1.0.0/source/guacamole-client-1.0.0.tar.gz" -O guacamole-client-1.0.0.tar.gz
tar -xzf guacamole-client-1.0.0.tar.gz
cd guacamole-client-1.0.0
mvn package (very long time on 1.2GHz Quad Core, take a break, 15-30mins)
cd guacamole/target/
ls guacamole-1.0.0.war
sudo mv guacamole-1.0.0.war /usr/share/jetty9/webapps/guacamole.war
sudo service jetty9 restart
http://192.168.1.3:8080/guacamole

install client war (1.4.0 debian 11 2022)
wget --user-agent=Mozilla \ -e robots=off "https://apache.org/dyn/closer.lua/guacamole/1.4.0/binary/guacamole-1.4.0.war?action=download" -O guacamole-1.4.0.war
ls guacamole-1.4.0.war
sudo mv guacamole-1.4.0.war /usr/share/jetty9/webapps/guacamole.war
sudo service jetty9 restart
http://192.168.1.3:8080/guacamole



configure
sudo mkdir /usr/share/jetty9/.guacamole
cd /usr/share/jetty9/.guacamole

sudo nano guacamole.properties
# Hostname and port of guacamole proxy
guacd-hostname: localhost
guacd-port:     4822
# Location to read extra .jar's from
lib-directory:  /usr/share/jetty9/.guacamole
# Authentication provider class
auth-provider: net.sourceforge.guacamole.net.basic.BasicFileAuthenticationProvider
# Properties used by BasicFileAuthenticationProvider
basic-user-mapping: /usr/share/jetty9/.guacamole/user-mapping.xml

sudo nano  /usr/share/jetty9/.guacamole/user-mapping.xml
<user-mapping>
    <authorize username="leungric" password="2d4b6753d3e94ef39a1de5cddef6aa44" encoding="md5">
        <connection name="pi 192.168.1.3 rdp">
             <protocol>rdp</protocol>
             <param name="hostname">192.168.1.3</param>
             <param name="port">3389</param>
       </connection>
       <connection name="pi 192.168.1.3 ssh">
             <protocol>ssh</protocol>
             <param name="hostname">192.168.1.3</param>
             <param name="port">22</param>
       </connection>
       <connection name="pi 192.168.1.3 vnc">
             <protocol>vnc</protocol>
             <param name="hostname">192.168.1.3</param>
             <param name="port">5900</param>
             <param name="password">Tin.netS1....</param>
       </connection>
    </authorize>
</user-mapping>

http://192.168.1.3:8080/guacamole
leungric
....
need sudo service jetty9 restart # not sudo /etc/init.d/guacd restart

ssh 8443 optional (unsuccessful, dont use, verify after 2021, working 2022)
# https://stackoverflow.com/questions/4008837/configure-ssl-on-jetty
cd /usr/share/jetty9
sudo openssl genrsa -des3 -out jetty.key
# enter 8 char pw
sudo openssl req -new -x509 -key jetty.key -out jetty.crt
# enter 8 char pw
# many default enter
sudo keytool -keystore keystore -import -alias jetty -file jetty.crt -trustcacerts
# enter 8 char pw
# trust? yes, cert added keystore
# try skip this line # sudo openssl req -new -key jetty.key -out jetty.csr
sudo openssl pkcs12 -inkey jetty.key -in jetty.crt -export -out jetty.pkcs12
# enter 8 char pw 3 times
sudo keytool -importkeystore -srckeystore jetty.pkcs12 -srcstoretype PKCS12 -destkeystore keystore
# enter 8 char pw
# 1 successfully imported

HTTPS/SSL (working 2022 with 0.9.13 and also 1.0.0)
cd /usr/share/jetty9
ls /usr/share/jetty9/start.jar
sudo java -jar /usr/share/jetty9/start.jar --add-to-startd=ssl,https
# many initialised, enabled in start.ini
sudo nano /usr/share/jetty9/start.d/https.ini
# https.port=8443, exit
sudo nano /usr/share/jetty9/start.d/ssl.ini
# jetty.secure.port=8443, exit
sudo service jetty9 restart
sudo service jetty9 status
sudo netstat -natup | grep -E "8080|8443"
# :::8443 :::8080 :::* LISTEN  3828/java
sudo ss -natup | grep -E "8080|8443"
https://192.168.1.3:8443/
https://192.168.1.3:8443/guacamole

RDP to Windows 10 and 11 (2022)
# https://stackoverflow.com/questions/44039126/guacamole-windows-10-rdp-failed
# https://stackoverflow.com/questions/44039126/guacamole-windows-10-rdp-failed
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp]
Change “SecurityLayer” value to 1 (from possibly value 2)
Verify “UserAuthentication” value is 0


2017年9月6日 星期三

MSSQL Server Express 2016 on Windows 10 with Docker

https://store.docker.com/editions/community/docker-ce-desktop-windows
Download Edge channel instead of stable channel
https://download.docker.com/win/edge/Docker%20for%20Windows%20Installer.exe

docker --version Docker version
docker-compose --version
docker-machine --version
docker ps
docker version
docker info

docker run hello-world
docker run -it ubuntu bash
docker pull microsoft/nanoserver
docker run -it microsoft/nanoserver cmd

docker ps -a
docker images
docker commit [CONTAINER ID] [name]
docker start [CONTAINER ID]
docker attach [CONTAINER ID]
docker rm [CONTAINER ID]
docker rmi [REPOSITORY]

Windows

docker pull microsoft/mssql-server-windows-express
docker run -d -p 1433:1433 --env sa_password=BenitoTing --isolation=hyperv microsoft/mssql-server-windows-express
docker start 791c5b93d43a
docker exec -it 791c5b93d43a sqlcmd -S. -U sa -P BenitoTing
docker inspect --format='{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 791c5b93d43a
172.25.153.226
172.25.153.226\SQLEXPRESS
sa
BenitoTing


Linux

docker pull microsoft/mssql-server-linux
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=<YourStrong!Passw0rd>" -e "MSSQL_PID=Developer" --cap-add SYS_PTRACE -p 1434:1433 -d microsoft/mssql-server-linux
docker ps -a
70834e12fba6
docker exec -it 70834e12fba6 /opt/mssql-tools/bin/sqlcmd -S. -U sa -P "<YourStrong!Passw0rd>"
docker inspect --format='{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' 70834e12fba6
172.17.0.2
172.17.0.2\SQLEXPRESS
sa
<YourStrong!Passw0rd>

docker stop 70834e12fba6
docker commit 70834e12fba6 dockermssql
docker run -p 21433:1433 -d --name db dockermssql

2017年9月4日 星期一

Installing IIS on Windows 10 with PHP CGI for Encode Explorer

Install IIS and Encode Explorer
appwiz.cpl
install IIS as feature
encode_explorer_6.4.1.tar.gz
copy index.php to the website directory

Install PHP 7
Microsoft Web Platform Installer 5.0
wpilauncher.exe 114KB
PHP 7.1.7 (x64) For IIS Express 18/1/2017, Add, Install
PHP_via_FastCGI Error? See next

Install CGI
Turn Windows features on or off
IIS > Web Management Tools > World Wide Web Services > Application development Features > CGI
HTTP Error 404.3 - Not Found? See Next

IIS > MIME Types > .log text/plain

2017年8月31日 星期四

INSTALL GUACAMOLE ON CENTOS 7 & 6 (THE SUPER EASY WAY)

Install guacamole
yum install -y wget
wget http://sourceforge.net/projects/guacamoleinstallscript/files/CentOS/guacamole-install-script.sh
sudo chmod +x guacamole-install-script.sh
sudo ./guacamole-install-script.sh

Use guacamole
http://IP-of-your-CentOS-VM:8080/guacamole/
https://IP-of-your-CentOS-VM:8443/guacamole/
Default username and password is guacadmin
Login and press Ctrl+Alt+Shift at least twice to feel it
Create a new user leungric and allow following
Create new connections
Create new connection groups
Create new sharing profiles
Change own password


https://thatservernerd.com/2016/02/25/install-guacamole-on-centos-76-the-super-easy-way/


If you haven’t checked out Guacamole, you seriously need to, but if you’ve been homelabbing for awhile then you’ve probably at least heard of it. Guacamole is an open-source HTML5-based clientless remote desktop gateway, allowing you to remotely connect to your devices via a simple webpage. It works with RDP, SSH, Telnet (but please use SSH instead if you can, guys), and VNC, and it is one of my absolute favorite tools.
I will admit that it’s not uncommon for me to create a new Linux server VM, install something pretty cool, say “This is pretty cool!”, and then never use that VM ever again. But Guacamole is the one that I show off to everyone because of how convenient it is and how well it works. Even if who I’m showing it off to isn’t into homelabs, system administration, or Linux, they always seem to think Guacamole is great. But the one thing that stops a lot of people from using it is the install process (though you can now easily deploy it in Docker).
Well thanks to this handy script, that’s no longer the case. I’ve installed Guacamole on Ubuntu and CentOS but I figured some people that might be reading this aren’t familiar with any Linux distro or Docker, so I wanted to find the simplest way possible to install Guacamole for someone that might be new to both.
What I found was this awesome script written by Hernan that was posted on his Sourceforge page. Here’s a description of the script according to his page:
“The script installs dependencies and configure the OS automatically for you in order to obtain the best Remote Desktop Gateway!
This Install Script works in a clean CentOS 6/7 installation and install Guacamole 0.9.9 version for a local users authentication.
Task of this script:
  • Install Packages Dependencies
  • Download Guacamole and MySQL Connector packages
  • Install Guacamole Server
  • Install Guacamole Client
  • Install MySQL Connector
  • Configure MariaDB or MySQL
  • Configure FirewallD or iptables
  • Setting Tomcat Server
  • Generates a Java KeyStore for SSL Support.”
I’ve tested out his script and it works perfectly. It makes it extremely easy for even the biggest Linux noobs to get Guacamole working on CentOS 7 or 6. If you want to use Guacamole in your homelab environment, here are the steps to get it going using Hernan’s script (assuming you have a fresh minimal install of CentOS ready to go).
**Update 3/30/16**
I updated this tutorial to use Hernan’s latest script. This adds the option to install Nginx as a proxy for Guacamole during the wizard.
How to install Guacamole on CentOS 7/6 the super easy way
1. (Assuming you’re logged in as root), type in the following to install Wget:
yum install -y wget
2. Let’s download the script using wget:
wget http://sourceforge.net/projects/guacamoleinstallscript/files/CentOS/guacamole-install-script.sh
3. Now let’s make sure we can execute the script:
chmod +x guacamole-install-script.sh
4. Execute!
./guacamole-install-script.sh
5. The script is going to take awhile to run while it downloads and installs everything that needs to download and install. Once it’s done, you’ll see the below screenshot asking you to create a root password for MariaDB, the Guac DB name, username, and password, then finally the Java KeyStore password. Don’t use the ones I used and don’t forget what they are.
2
6. Once at the wizard for the Java KeyStore, go ahead and fill out your information.
3
7. Once you see the screenshot below, you’ve officially installed Guacamole! All that’s left is to go to the page at http://IP-of-your-CentOS-VM:8080/guacamole/ or https://IP-of-your-CentOS-VM:8443/guacamole/ and start adding some remote connections. Default username and password is guacadmin.
35

Adding your first connections in Guacamole
Adding remote connections is pretty self-explanatory, but you can follow my instructions below if you’d like some guidance. The examples I’ve added below are a Windows 10 workstation using RDP and an HP Procurve (err I mean Aruba or whatever HP is calling their product this week) switch of mine using SSH.
1. Once you go to your Guacamole web UI, you’ll see the screenshot below. Go ahead and login with the default username and password guacadmin (don’t forget to change the default password).
4
2. (Optional) I suggest creating your own user account outside of guacadmin (after changing the default password). Click on the guacadmin dropdown menu in the upper right and then Settings. Go to Users, New User, and fill out the Username & Password fields. For my account, I also checked all the permissions except “Administer system” and “Create new users” (I leave that up for the guacadmin account). Now log out of guacadmin and log into your new account.
3. Click on the username dropdown menu in the upper right and then Settings. Under the Connections tab, click New Connection.
4. For a Windows machine, let’s create an RDP connection. The screenshot below is a working configuration for my Windows 10 workstation. Under Authentication, you might have to experiment with different “Security modes” and maybe check “Ignore server certificate to get it properly connecting.
6
NOTE: If you’re having trouble getting it to connect after experimenting with the Security modes, you can try unchecking “Allow connections only from computers running Remote Desktop with Network Level Authentication” in Windows’s System Properties (shown below), then clearing “Security mode” and “Ignore server certificate” in the Connection settings in Guacamole.
65
5. Let’s add a remote connection using SSH (like a Linux machine, networking device, etc.). Below is the working Connection settings for my main switch.
7
6. Once you’ve got an RDP and an SSH connection saved, let’s go to the homepage (username dropdown menu then Home). Now click on any of the connections you just created. Below are screenshots of both my Windows workstation and main switch remoted into.
Congrats! You now have a fully functional Guacamole server! If you followed the steps on adding some remote connections, you should now be able to see how well remoting into your devices works in any browser using HTML5. Using that script, even the noobiest(?) of Linux noobs can get a Guacamole server up and running in no time and with minimal effort.
I just wanted to thank Hernan for letting me post his script. If you’d like to check out his blog, you can do so by clicking here.

2017年8月21日 星期一

Raspberry Pi 3 Installation Guide ARM Java Firefox Wifi Minoconda Python

CentOS-Userland-7-armv7hl-Minimal-1611-RaspberryPi3.img.xz 2016-12-09 10:12 312M
Win32 Disk Imager

put card to rpi3 connecting to router
router check rpi3 ip address

connect to rpi3
ssh root@192.168.31.90
centos
yum -y update

check disk space only has 2GB
fdisk -l
df -h

roots-expand
/usr/local/bin/rootfs-expand

install wifi
curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin> /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt
systemctl reboot
ip addr | grep wlan

ntp
yum -y install ntp
timedatectl set-ntp yes

set time zone
timedatectl list-timezones | grep "Asia"
timedatectl set-timezone "Asia/Hong_Kong"

set locale
localectl list-locales | grep "en"
localectl set-locale LANG="en_US.UTF-8" LC_CTYPE="en_US"
localectl

set autocomplete
yum install -y bash-completion

setup wifi
ip addr show
nmcli connection show
nmtui
activate using device "wlan0"

install jdk 8
wget --no-check-certificate --no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u144-b01/090f390dda5b47b9b721c7dfaa008135/jdk-8u144-linux-arm32-vfp-hflt.tar.gz
tar -zxvf jdk-8u144-linux-arm32-vfp-hflt.tar.gz -C /usr/local/java
export JAVA_HOME=/usr/local/java export PATH=$JAVA_HOME/bin:$PATH
sudo vi /etc/profile.d/java.sh
export JAVA_HOME=/usr/local/java/jdk1.8.0_144
export PATH=$JAVA_HOME/bin:$PATH
java -verson

Minoconda Python 2.7.5
wget https://repo.continuum.io/miniconda/Miniconda-latest-Linux-armv7l.sh
chmod +x Miniconda-latest-Linux-armv7l.sh
./Miniconda-latest-Linux-armv7l.sh
ctrl+F, yes
/home/leungric/miniconda
sudo nano ~/.bashrc
# added by Miniconda 3.16.0 installer
export PATH="/home/leungric/miniconda/bin:$PATH"
python --version
conda install anaconda-client
asd

install firefox
sudo yum install bzip2
cd /usr/local
wget http://ftp.mozilla.org/pub/firefox/releases/55.0/linux-x86_64/en-US/firefox-55.0.tar.bz2
tar xvjf firefox-55.0.tar.bz2

2017年8月19日 星期六

樹莓派 3(Raspberry Pi 3) CentOS 7 ARM 安裝與配置


http://www.smalljacky.com/linux/centos/raspberry-pi-3-centos7-arm-install-setup/



樹莓派 3(Raspberry Pi 3) CentOS 7 ARM 安裝與配置




終於可以在「樹莓派 3」上使用 CentOS 了。本篇文章將詳細說明如何在「樹莓派 3」安裝 CentOS 7 ARM 系統,與首次使用的一些設定,如系統更新、自動調整分割區容量、驅動 wifi、時區設定、語系設定...

下載與燒錄映像檔

至 CentOS 官網下載連結 下載「樹莓派 3」的壓縮檔版本(支援樹莓派 2、樹莓派 3)。

先將壓縮檔裡的 .img(映像檔)解壓縮,並參考 Win32 Disk Imager 備份與燒錄 SD 卡 這篇文章將檔案燒錄至「Micro SD 記憶卡」,燒錄完成後:
  1. 將「Micro SD 記憶卡」插入「樹莓派 3」
  2. 接上網路線(網路設備必須支援 DHCP,且須與電腦同一網段)
  3. 「樹莓派 3」開機
接著進入網路設備查看「CentOS 7 ARM」DHCP 分配的網址(或使用網路網段掃描軟體,如 SoftPerfect Network Scanner)。

連結 CentOS 7 ARM

開啟 PieTTY 軟體 > [主機名稱或IP位址(N)] 輸入 IP > [Port] SSH 預設為 22 Port > 點擊 [連線]。
 PieTTY 軟體,可至 PieTTY (pputty) 下載

第一次使用 SSH 連線的主機,會提示是否儲存憑證,點擊 [是(Y)] 即可。

登入「CentOS 7 ARM」預設的帳戶:
  • 帳戶:root
  • 密碼:centos
login as: root
root@192.168.0.156's password: ******
[root@centos-rpi3 ~]#

CentOS 7 ARM 初始設置

系統更新

先更新所有套件、軟體與核心:
 100 多個更新,約 10 幾分才完成…
[root@centos-rpi3 ~]# yum -y update

CentOS 7 ARM README(說明文件)

在 root 家目錄下有一個 README 檔案:
[root@centos-rpi3 ~]# ll
total 4
-rw-r--r--. 1 root root 548 Dec  5 16:28 README
查看該檔案,說明使用「樹莓派 3」要做的兩件事:
  • 自動調整分割區容量
  • 驅動「樹莓派 3」的 wifi
[root@centos-rpi3 ~]# cat README
== CentOS 7 userland ==

If you want to automatically resize your / partition, just type the following (as root user):
/usr/local/bin/rootfs-expand

For wifi on the rpi3, just proceed with those steps :

curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin > /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin

curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt

systemctl reboot

自動調整分割區容量

先查看目前的容量:
[root@centos-rpi3 ~]# fdisk -l

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes, 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006dc70

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048     1026047      512000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2         1026048     2074623      524288   82  Linux swap / Solaris
/dev/mmcblk0p3         2074624     6268927     2097152   83  Linux

[root@centos-rpi3 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root       2.0G  995M  839M  55% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  451M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  500M   49M  452M  10% /boot
tmpfs            93M     0   93M   0% /run/user/0
 
依 README 執行如下指令,來自動調整分區容量:
[root@centos-rpi3 ~]# /usr/local/bin/rootfs-expand
查看調整後的容量,增加了不少:
[root@centos-rpi3 ~]# fdisk -l

Disk /dev/mmcblk0: 15.9 GB, 15931539456 bytes, 31116288 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0006dc70

        Device Boot      Start         End      Blocks   Id  System
/dev/mmcblk0p1            2048     1026047      512000    c  W95 FAT32 (LBA)
/dev/mmcblk0p2         1026048     2074623      524288   82  Linux swap / Solaris
/dev/mmcblk0p3         2074624    31116287    14520832   83  Linux

[root@centos-rpi3 ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        14G  999M   13G   8% /
devtmpfs        459M     0  459M   0% /dev
tmpfs           463M     0  463M   0% /dev/shm
tmpfs           463M   12M  451M   3% /run
tmpfs           463M     0  463M   0% /sys/fs/cgroup
/dev/mmcblk0p1  500M   49M  452M  10% /boot
tmpfs            93M     0   93M   0% /run/user/0

驅動「樹莓派 3」的 wifi

查看目前啟用的網路介面只有一個 eth0 有線網路裝置,wifi 並沒有驅動:
[root@centos-rpi3 ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 100                                                                                  0
    link/ether b8:27:eb:04:29:8a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.156/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 6580sec preferred_lft 6580sec
    inet6 fe80::ba27:ebff:fe04:298a/64 scope link
       valid_lft forever preferred_lft forever 
依 README 執行如下指令,來安裝 wifi 的驅動:
[root@centos-rpi3 ~]# curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.bin> /usr/lib/firmware/brcm/brcmfmac43430-sdio.bin
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   172  100   172    0     0     84      0  0:00:02  0:00:02 --:--:--    84
100  360k  100  360k    0     0  87259      0  0:00:04  0:00:04 --:--:--  170k

[root@centos-rpi3 ~]# curl --location https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm80211/brcm/brcmfmac43430-sdio.txt > /usr/lib/firmware/brcm/brcmfmac43430-sdio.txt
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   172  100   172    0     0     92      0  0:00:01  0:00:01 --:--:--    92
100  1108  100  1108    0     0    388      0  0:00:02  0:00:02 --:--:--  1631
重啟系統:
[root@centos-rpi3 ~]# systemctl reboot
再查看目前啟用的網路介面多了一個 wlan0,也就是 Wireless Lan:
[root@centos-rpi3 ~]# ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
    link/ether b8:27:eb:04:29:8a brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.156/24 brd 192.168.0.255 scope global dynamic eth0
       valid_lft 6107sec preferred_lft 6107sec
    inet6 fe80::ba27:ebff:fe04:298a/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0:  mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
    link/ether 7a:d5:ba:e9:57:fb brd ff:ff:ff:ff:ff:ff

時區設定

查看目前系統的預設時區為 UTC,會比我們台灣的時間快 4 小時:
[root@centos-rpi3 ~]# timedatectl
      Local time: 六 2017-03-25 12:11:17 UTC
  Universal time: 六 2017-03-25 12:11:17 UTC
        RTC time: n/a
       Time zone: UTC (UTC, +0000)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a
先查看與“Asia”相關的時區有哪些:
[root@centos-rpi3 ~]# timedatectl list-timezones | grep "Asia"
... 以上省略 ...
Asia/Srednekolymsk
Asia/Taipei
Asia/Tashkent
... 以下省略 ...
設定時區,並查看:
[root@centos-rpi3 ~]# timedatectl set-timezone "Asia/Taipei"
[root@centos-rpi3 ~]# timedatectl
      Local time: 六 2017-03-25 20:19:23 CST
  Universal time: 六 2017-03-25 12:19:23 UTC
        RTC time: n/a
       Time zone: Asia/Taipei (CST, +0800)
     NTP enabled: yes
NTP synchronized: yes
 RTC in local TZ: no
      DST active: n/a 

語系設定

查看目前設定的語系,可以看到「CentOS 7 ARM」並沒有指定語系:
[root@centos-rpi3 ~]# localectl
   System Locale: n/a

       VC Keymap: n/a
      X11 Layout: n/a
查看所有支援的語系:
[root@centos-rpi3 ~]# localectl list-locales
or 查看與“TW”相關的語系:
[root@centos-rpi3 ~]# localectl list-locales | grep "TW"
nan_TW.utf8@latin
nan_TW@latin
zh_TW
zh_TW.big5
zh_TW.euctw
zh_TW.utf8
設定台灣使用的“zh_TW.utf8”語系,並查看:
[root@centos-rpi3 ~]# localectl set-locale LANG=zh_TW.utf8
[root@centos-rpi3 ~]# localectl
   System Locale: LANG=zh_TW.utf8
       VC Keymap: n/a
      X11 Layout: n/a
重啟系統:
[root@centos-rpi3 ~]# systemctl reboot

其它

自動帶出相關指令;直接完成指令

在命令列輸入指令開頭 1 或多個字母後 [TAB][TAB] 鍵即可:
  • 自動帶出相關指令:有匹配多個
  • 直接完成:匹配一個
先安裝相關套件:
[root@centos-rpi3 ~]# yum install -y bash-completion
登出並重新登入後測試:
[root@centos-rpi3 ~]# logout
login as: root
root@192.168.0.156's password: ******
[root@centos-rpi3 ~]# systemctl res[TAB][TAB]
rescue        reset-failed  restart

2023 Promox on Morefine N6000 16GB 512GB

2023 Promox on Morefine N6000 16GB 512GB Software Etcher 100MB (not but can be rufus-4.3.exe 1.4MB) Proxmox VE 7.4 ISO Installer (1st ISO re...