顯示具有 ubuntu 標籤的文章。 顯示所有文章
顯示具有 ubuntu 標籤的文章。 顯示所有文章

2013年10月31日 星期四

Provide a sftp account but disable it's SSH access for a team member

[Target]
1. Using user 'sftp-user'
2. Store files on folder '/sftp-folder'
3. Allow a team member to access it
4. Using RSA public key for access control

[Step]
1. Prepare account 'sftp-user' and folder '/sftp-folder'
   Create a user 'sftp-user'
   Create a folder 'sftp-folder' on /
   Change the folder owner to root; 'chown root /sftp-folder'

2. Modify SSHd setting, edit /etc/ssh/sshd_config

  sudo vi /etc/ssh/sshd_config

================================================================
#Subsystem sftp /usr/lib/openssh/sftp-server
Subsystem sftp internal-sftp

Match user sftp_user
  ChrootDirectory /sftp_folder
  AllowTcpForwarding no
  X11Forwarding no
  ForceCommand internal-sftp
=================================================================

3. To disable SSH for sftp-user
Modify /etc/passwd, change account 'sftp-user' shell program to /bin/false from /bin/bash

  sudo vi /etc/passwd

4. Edit permission list
Add RSA public keys to /home/sftp-user/.ssh/authorized_key

5. restart SSHd

  sudo /etc/init.d/ssh restart

[TEST]
You can generate a RSA public key on someone Linux, and provide it to sftp administrator.
After your key added to sftp-user's authorized_key file, you can using sftp to connect 'sftp-user' account

  sftp sftp-user@somehome.com

2012年12月28日 星期五

Using script file to mount ecryptfs file system


#!/bin/sh

echo 'passwd=12345678' > /tmp/mypasswd.txt

sudo mount -t ecryptfs test_ec test_ec -o \
key=passphrase:passfile=/tmp/mypasswd.txt,\
ecryptfs_cipher=aes,\
ecryptfs_key_bytes=16,\
ecryptfs_passthrough=y,\
ecryptfs_fnek_sig=617264405cf6d2f2

rm /tmp/mypasswd.txt


2011年4月6日 星期三

Change GRUB's default boot setting to windows

  • watch windows menuentry name
$ cat /boot/grub/grub.cfg

   ...
   menuentry "Microsoft Windows XP Professional (on /dev/sda1)" {
   ...



  • change GRUB_DEFAULT
$ sudo vi /etc/default/grub

   GRUB_DEFAULT="Microsoft Windows XP Professional (on /dev/sda1)"



  • update grub.cfg
$ sudo update-grub

2011年4月5日 星期二

Git 簡單指令使用

* 建立git database
$ git init

* 建立第一個進度點/版本(commit)
$ git add .
$ git commit -m "initial"

* 比對
$ git diff master
* 產生patch
$ git diff master > xxx.patch

* 放棄修改, 恢復到目前的commit
$ git checkout -f

* 列出commit
$ git log --pretty=oneline

14b26e3e80941f8290019f63231fb8b03ff805c1 initial


* 給予標籤
$ git tag -a v0.1  14b26e



========================================
* 使用patch
patch -p1 < xxx.patch

2011年3月31日 星期四

A problem about the character 0xD is be changed to 0xA

== LF/CR issue with RS232 in Linux ==

stty -F /dev/ttyS0 -onlcr
stty -F /deb/ttyS0 -icrnl


2011年3月11日 星期五

Redirect stderr to file

IO index is:
1 is stdout
2 is stderr

===Redirect stderr to 'log.txt' file===

$ someprogram  2> log.txt

===Redirect stderr to stdout===

$ someprogram 2>&1 | less

===Redirect stderr and stdout to a file===

$ someprogram &> log.txt

2011年2月25日 星期五

Enable telnetd service

  • Install package
for Ubuntu or debain
# sudo apt-get install xinetd telnetd
or
for Angstrom Distribution
# opkg install netkit-telnet xinetd

  • Edit /etc/xinetd.conf


# vi /etc/xinetd.conf

defaults
{
        instances = 60
        log_type = SYSLOG authpriv
        log_on_success = HOST PID
        log_on_failure = HOST
        cps = 25 30
}
includedir /etc/xinetd.d


  • Edit /etc/xinetd.d/telnet

# vi /etc/xinetd.d/telnet

service telnet
{
        disable = no
        flags = REUSE
        socket_type = stream
        wait = no
        user = root
        # server = /usr/sbin/in.telnetd
        server = /usr/sbin/telnetd
        log_on_failure += USERID
}

  • Execute xinitd service
# /etc/init.d/xinetd restart

2011年1月5日 星期三

Ubuntu/Linux 下使用UART console/terminal

Ubuntu/Linux 下使用UART console/terminal

1. 下載minicom
sudo apt-get install minicom

2. 設定minicom
sudo minicom -s

2.1. 修改Modem 的通訊設定(Serial port setup),將Baund rate 設為 115200,資料位元設為 8,無同位元,停止位元設為 1 (Bps/Par/Bits:115200 8N1), 硬體Flow控制為off,
指定連接 Console的序列埠 (Serial Device);其中/dev/ttyS0表示 COM1,/dev/ttyS1為 COM2、/dev/ttyUSB0為 USB to UART

2.2. 接著修改Modem 的撥接設定(Modem and dialing), 將Init string 和Reset string 都設為空白

2.3. 儲存設定(Save setup as df1)

2010年12月29日 星期三

Let some command without input password

1) execute visudo to edit the script of sudoer
sudo visudo

2) add below text in editor, hit ctrl-x and 'Y' to save it
wnc ALL= NOPASSWD: /sbin/shutdown


2010年12月8日 星期三

touchscreen calibration


From: Tias 
There is now a generic touchscreen calibration utility that can 
calibrate evtouch, as well as evdev (the now preferred upstream driver 
for touchscreens) and others.

I've uploaded it to mentors and mailed:
http://lists.debian.org/debian-mentors/2010/08/msg00066.html

You can download a binary deb package on the website:
http://github.com/tias/xinput_calibrator/downloads

More info on the homepage:
http://www.freedesktop.org/wiki/Software/xinput_calibrator



2010年1月26日 星期二

to enable wifi driver and WPA_supplicant

#!/bin/sh
# load wifi driver
insmod sdio.ko
insmod tiwlan_drv.ko
tiwlan_loader
ifconfig tiwlan0 up

#
# the content of /data/misc/wifi/wpa_supplicant.conf
#
# ctrl_interface=/var/run/wpa_supplicant
# ap_scan=1
# update_config=1
#
# #any AP
# network={
# key_mgmt=NONE
# }
#
# #WEP key
# network={
# ssid="xwlan"
# key_mgmt=NONE
# wep_key0="12345"
# wep_key1=31323334353536383930313233
# wep_tx_keyidx=0
# }
#
# #WPA or WPA2
# network={
# ssid="xwlan"
# key_mgmt=WPA-PSK
# psk="hellohello"
# }
#

#make sure /var/run folder is existence
#mkdir /var; mkdir /var/run

# execute wpa_supplicant
wpa_supplicant -Dtiwlan0 -itiwlan0 -c/data/misc/wifi/wpa_supplicant.conf -dd &

# wpa_cli is a CLI application
#wpa_cli -p/var/run/wpa_supplicant

# dispatch ip address
#ifconfig tiwlan0 192.168.5.11 netmask 255.255.255.0 up
/system/bin/dhcpcd -BKL -d tiwlan0 &

# telnetd
#/data/bin/busybox telnetd -l /system/bin/sh


2009年12月17日 星期四

To Enable NAT feature

* Edit a new script file nat.sh

vi /etc/init.d/nat.sh

#!/bin/sh
##### iptables.rule #####
EIF="eth0" # 對外的網路介面
IIF="eth1" # 對內的網路介面
INNET="192.168.5.0/24" # 內部子網域

# forwarding
# 讓內部網路的封包可以轉送到外部
echo "1" > /proc/sys/net/ipv4/ip_forward

# flush all rules
iptables -F
iptables -X
iptables -t nat -F
iptables -t nat -X

# 定義 policy
# Policy指的是當進來的封包不屬於rule中的任何一條時,所預設的動作。
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT

# localhost
iptables -A INPUT -i lo -j ACCEPT
iptables -A OUTPUT -o lo -j ACCEPT

# 讓主機主動建立的連線可以進來
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

# 設定主機上提供的服務可讓外部網路存取
iptables -A INPUT -i $EIF -p udp --dport 22 -j ACCEPT #ssh
iptables -A INPUT -i $EIF -p udp --dport 22 -j ACCEPT
iptables -A INPUT -i $EIF -p tcp --dport 80 -j ACCEPT # http
# ... 其餘省略

# enable any connection for local LAN
iptables -A INPUT -i eth1 -j ACCEPT
iptables -A OUTPUT -o eth1 -j ACCEPT

# NAT
iptables -t nat -A POSTROUTING -o $EIF -s $INNET -j MASQUERADE


* add the file into /etc/rc.local


Reference:
http://ljhuang.pixnet.net/blog/post/15029442


To enable dhcp server for mutil-interface

Under Ubuntu 8.04.3

* get DHCP server
sudo apt-get install dhcp3-server

* enable networking interface for DHCP server
sudo vi /etc/default/dhcp3-server

# what interface provide DHCP service
INTERFACES="wlan0 eth1"


* edit the DHCP server parameter
sudo vi /etc/dhcp3/dhcpd.conf

ddns-update-style none;
log-facility local7;

subnet 192.168.5.0 netmask 255.255.255.0 {
option routers 192.168.5.1;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.5.255;
option domain-name-servers 172.16.100.1, 172.16.100.16;
# option ntp-servers 172.16.100.1;
# option netbios-name-servers 172.16.100.1;
option netbios-node-type 2;
default-lease-time 86400;
max-lease-time 86400;

range 192.168.5.21 192.168.5.30;
}


Reference:
https://help.ubuntu.com/community/dhcp3-server



2009年12月6日 星期日

To access USB serial port

* In order to pre-mount USB device file system when system boot-up, to add parameter to /etc/fstab (in linux kernel 2.6)
$ vi /etc/fstab

none /proc/bus/usb usbfs defaults,devmode=0666 0 0

* Auto mount it
$ mount -a


ex: you can access USB serial port by device file /dev/ttyUSB0 or ttyUSB1


2009年12月1日 星期二

重建mutil OS boot loader - GRUB

如果GRUB 原本安裝在MBR區
  • 準備WINGRUB, 在XP下將 grub 安裝到MBR
重建GRUB
  • 準備 linux live-CD, 開機進入live-CD mode
  • 在終端機執行 grub
  • grub> root (hd0,0)
    grub> setup (hd0)
    grub> quit



colinux Root FS image for ubuntu8.04

colinux Root FS image for ubuntu8.04

1. execute stable-coLinux-20080416.exe to install on c:\colinux folder or other folder.

2. extract ubuntu8colinux.rar to D:\

3. run cai.bat on d:\ubuntu8colinux folder.

4. ID/passwd is root/root

5. you can install ubuntu softwares with apt-get install xxx/apt-get update/apt-get upgrade

6. It is a tips, if you use local install ubuntu package.
Please use below steps:
(1)You can copy *.deb file to d:\ubuntu8colinux\xfs folder on the windows
(2) mv /opt/*.deb /var/cache/apt folder in the colinux command line.
(3) apt-get xxx package name to install ubuntu packages.

Detail to access http://www.colinux.org

other documents: to download ubuntu8colinux.cai.rar file from http://groups.google.com/group/iyaf site


1)ubuntu8colinux.rar下載地址http://www.fs2you.com/files/79fe4b00-13d1-11dd-9776-0014221f3995/

ubuntu8colinux.rar

2)others documents:
http://groups.google.com/group/iyaf
ubuntu8colinu.cai.rar

3)deb files:
http://www.fs2you.com/files/2c5caae1-db2b-11dc-9f83-00142218fc6e/
deb.rar
copy *.deb file to /var/cache/apt/archives and install with apt-get install xxx.



reference:

build Android under Ubuntu 9.10

  • Ubuntu 9.10 users may need to install a newer version of standard C++ library
$sudo apt-get install libstdc++6 
  • Ubuntu 9.10 users may need to add the old Jaunty repos to their /etc/apt/sources.list to install sun-java5-jdk
deb http://us.archive.ubuntu.com/ubuntu/ jaunty multiverse deb http://us.archive.ubuntu.com/ubuntu/ jaunty-updates multiverse


Reference: http://omappedia.org/wiki/Android_Getting_Started

2009年11月25日 星期三

source list for ubuntu 8.04.3

# /etc/apt/source.list

deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy main universe restricted multiverse
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy main universe restricted multiverse

deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security universe main multiverse restricted
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-security universe main multiverse restricted

deb http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates universe main multiverse restricted
deb-src http://ftp.twaren.net/Linux/Ubuntu/ubuntu/ hardy-updates universe main multiverse restricted


deb ftp://os.nchc.org.tw/ubuntu/ hardy main universe restricted multiverse
deb-src ftp://os.nchc.org.tw/ubuntu/ hardy main universe restricted multiverse
deb ftp://os.nchc.org.tw/ubuntu/ hardy-security universe main multiverse restricted
deb-src ftp://os.nchc.org.tw/ubuntu/ hardy-security universe main multiverse restricted
deb ftp://os.nchc.org.tw/ubuntu/ hardy-updates universe main multiverse restricted
deb-src ftp://os.nchc.org.tw/ubuntu/ hardy-updates universe main multiverse restricted



# if your PC connect to internet via proxy, please add below command into ~/.bashrc
# export http_proxy=http://192.168.0.12:8080
# export ftp_proxy=http://192.168.0.12:8080