Pages - Menu

標籤

AWS (1) bash (1) Boost (2) C (2) CMake (2) Concurrency_Programming (3) CPP (37) Database (2) DNS (1) Docker (4) Docker-Compose (1) ELK (1) emacs (4) gcp (1) gdrive (1) git (1) gitbash (2) gitlab (1) kvm (4) Linux (5) MT4 (4) MT5 (4) Multicast (2) MySQL (2) Nijatrader8 (1) OpenCV (1) Python (4) QT5 (1) R (1) rdp (3) screenshot (1) ssh (3) Tabnine (1) TCP (1) TensorFlow (1) Tools (12) Ubuntu_1904 (11) Ubuntu_20_04 (5) UDP (1) VS2010 (1) VS2015 (1) VS2019 (1) WebServer (1) Win10 (1) winmerge (1) WSL (1) xrdp (1)

搜尋此網誌

2019年6月14日星期五

Ubuntu KVM Installation

 On Ubuntu 20.04

Steps

# check if cpu virtualizable, if you machine report a number greater than 0, then you can use kvm
$ egrep -c '(vmx|svm)' /proc/cpuinfo

# check if VT is enabled, you can go to bios to enable it
$ sudo apt-get install cpu-checker
$ kvm-ok

# install things you needed
$ sudo apt-get install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virt-manager

# check if the daemon is running
$ sudo systemctl is-active libvirtd

# check for user group
$ id <userName>

# add user to group
$ sudo adduser <userName> libvirt
$ sudo adduser <userName> kvm

# copy and paste, mouse lag setup
# install spice-space on client OS
https://www.spice-space.org/download.html

 Use

$ sudo virt-manager

 On Ubuntu 18.04

Steps


# check if virtualization support, 0 is not support
$ egrep -c ‘(svm|vmx)’ /proc/cpuinfo
$ sudo apt-get install qemu-kvm libvirt-bin bridge-utils virt-manager
$ sudo addgroup libvirtd
$ sudo adduser YourUserName libvirtd

# log out and log in
$ virsh -c qemu:///system list
# If you see an empty list, then it works

Install guest OS

  • Then follow the steps on the GUI

Reference

https://getlabsdone.com/install-windows-10-on-ubuntu-kvm/

https://getlabsdone.com/how-to-install-windows-11-on-kvm/

Docker cheat sheet

Install

Steps


$ sudo apt update
$ sudo apt install apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt update
$ sudo apt install docker-ce
$ sudo systemctl status docker
$ docker -v

Cheat sheet


# list all image
$ sudo docker image ls
# list all container
$ sudo docker ps -a
$ sudo docker container ls --all
# remove image
$ sudo docker rmi IMAGE
# remove container
$ sudo docker rm CONTAINER
# remove all container
$ sudo docker rm $(sudo docker ps -a -q)
# Go into running container
$ sudo docker exec -it <mycontainer> bash
# build image from Dockerfile
$ cd Target-folder
$ ls
Dockerfile
$ sudo docker build --tag=Name:tag .
# Stop container
$ sudo docker stop -t 1 <mycontainer>
# add xserver for docker
$ xhost +local:docker
# run an image
$ sudo docker run -v /host/directory:/container/directory -it Name:tag
$ sudo docker run --net=host --env="DISPLAY" --volume="$HOME/.Xauthority:/root/.Xauthority:rw" -v /host/directory:/container/directory -it Name:tag
# copy file/folder from/to container
$ sudo docker cp foo.txt mycontainer:/foo.txt
$ sudo docker cp mycontainer:/foo.txt foo.txt

Windows multiple remote desktop sessions

Aim

  • I want to have multiple RDP clients connecting to the windows host
  • Learn From

Steps


ubuntu 18.04 remote desktop client to windows

Aim

  • I want to connect to windows through Remote Desktop Protocol (RDP) from ubuntu 18.04
  • Learn From

Steps


  • Select the application


  • To activate share folder, you may need to follow those two red boxes.
  • Then you can connect to your Windows Host

2019年6月9日星期日

Draw on your screen on Ubuntu 18.04

$ sudo apt-get install tweak

$ sudo apt-get install gnome-shell-extensions

$ sudo apt-get install gnome-shell-extension-draw-on-your-screen

 restart - DONE 

 

Go to install the gnome shell extension, Link

2019年6月8日星期六

Install latest R on ubuntu 18.04


Ubuntu 18.04

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/'
$ sudo apt update
$ sudo apt install r-base
$ R --version

Ubuntu 19.04

$ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
$ sudo add-apt-repository 'deb https://cloud.r-project.org/bin/linux/ubuntu disco-cran35/'
$ sudo apt update
$ sudo apt install r-base
$ R --version

Learn from

2019年6月7日星期五

Fix ubuntu read only disk problem

Problem

When ubuntu 18.04 mount an NTFS disk, that is read only. We can do

sudo ntfsfix /dev/sdb1
sdb1 can be sda1, 2, 3 ......

After that, we can mount the disk again.
Learn from here

2019年6月6日星期四

Setup SSH reverse tunnel

Aim

We have PC A, PC B.
PC A is behind Proxy and we cannot change any setting about the network, PC B is behind NAT.
We want to use ssh to connect from B to A, so we need to make a reverse tunnel from A to B.

Assume you have setup the openssh server on PC B.

On PC A


$ ssh -R12345:localhost:22 <PC B userName>@<PC B ip> -p <PC B ssh server port> -i <PC B user private key>

  • The above command will connect remote port 12345 to local port 22
  • If you can connect to PC B, then

On PC B


$ ssh <PC B userName>@localhost -p 12345 -X

  • We now connected to PC A from B with x11 supported

Local port binding


ssh -Llocalhost:8888:[target IP]:[target port] -i [private key] [target user name]@[target IP]

Openssh server setup for public key login only

Aim

OS: ubuntu 18.04 64 bit
We want to have a ssh server that only accept login through rsa public key.

Installation

$ sudo apt-get install openssh-client openssh-server openssl

Server setting


$ sudo sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config
$ sudo sed -i 's/^PubkeyAuthentication no/PubkeyAuthentication yes/' /etc/ssh/sshd_config
$ sudo vim /etc/ssh/sshd_config
------------------------------------
PubkeyAuthentication yes
PasswordAuthentication no
------------------------------------
$ sudo systemctl restart sshd.service 

Generate rsa key pairs

$ ssh-keygen -t rsa -b 4096 -C "testing@gmail.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/sulfred/.ssh/id_rsa): id_testing
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in id_testing.
Your public key has been saved in id_testing.pub.
The key fingerprint is:
SHA256:6F/Pnyj3A96+qgSGrw4hQc+O2x2xrdBGA5lmznqllOY testing@gmail.com
The key's randomart image is:
+---[RSA 4096]----+
|  . .o           |
| . o=.           |
|  .=o.+          |
|   +*o.B         |
|  o=+oB S        |
|  .+E* = .  .    |
|  ..o + . o. o   |
|     . o o.oo.o. |
|     .o . .+==*o |
+----[SHA256]-----+

Add Authorized keys to server


$ cat id_testing.pub >> ~/.ssh/authorized_keys
$ ls -hal ~/.ssh
------------------------------------
-r--r--r--  1 you you  405 Jun  7 09:42 authorized_keys
-rw-------  1 you you 3.2K Jun  7 10:48 id_testing
-rw-r--r--  1 you you  743 Jun  7 10:48 id_testing.pub
------------------------------------
$ sudo service ssh restart