Saturday, May 24, 2014

restart the wireless on acer 5745

root@cb-DOC:~# modprobe -r brcmsmac ; modprobe brcmsmac

root@cb-DOC:~# ifconfig wlan0
wlan0     Link encap:Ethernet  HWaddr 5c:ac:4c:b0:3f:4d
          inet addr:192.168.1.2  Bcast:192.168.1.15  Mask:255.255.255.240
          inet6 addr: fe80::5eac:4cff:feb0:3f4d/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:242082 errors:0 dropped:0 overruns:0 frame:0
          TX packets:210420 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:272178906 (259.5 MiB)  TX bytes:36995927 (35.2 MiB)

mine is a subnetted network /28

root@cb-DOC:~# iwconfig
lo        no wireless extensions.

vmnet8    no wireless extensions.

wlan0     IEEE 802.11bgn  ESSID:"Wiz@dmin"
          Mode:Managed  Frequency:2.417 GHz  Access Point: 4C:60:DE:D5:68:63
          Bit Rate=57.8 Mb/s   Tx-Power=19 dBm
          Retry  long limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=44/70  Signal level=-66 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:748  Invalid misc:333   Missed beacon:0

eth0      no wireless extensions.

vmnet1    no wireless extensions.

For more information view the doc

root@cb-DOC:~# view /usr/share/doc/wireless-tools/README.Debian




Identify the program accessing a file on Linux

Make sure you check man page for fuser for more of the many switches which can be really handy..

wiz@cb-DOC:~$ man 1 fuser

Here we are just finding which program or thread is accessing a file, and it can be done as follows..

wiz@deb-DOC:~$ sudo fuser /var/log/syslog
/var/log/syslog:      3234 ---> pid of rsyslog (rsyslog since i'm running debian here)

and we also may use the lsof to do the same job and many more..

Make sure you check man page for lsof for many more switches which can be really handy..

wiz@cb-DOC:~$ man 8 lsof

wiz@deb-DOC:~$ lsof /var/log/syslog
wiz@deb-DOC:~$ sudo lsof /var/log/syslog
COMMAND   PID USER   FD   TYPE DEVICE SIZE/OFF    NODE NAME
rsyslogd 3234 root    1w   REG    8,2    35170 7079847 /var/log/syslog

HTH

Webcam streaming on VLC Player

Hello.. Here is the Fun Stuff..

Using the vlc player to live stream the video capture from your webcam.. You can also use any other player like mplayer provided you have it installed..

Now, here is what you need to do..

Webcam streaming on VLC Player

wiz@cb-DOC:~/sudo apt-cache search v4l-conf
v4l-conf - tool to configure video4linux drivers

wiz@cb-DOC:~/Downloads$ vlc v4l://
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0xe0e108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.

wiz@cb-DOC:~/Downloads$ sudo apt-get install v4l-conf
[sudo] password for wiz:
Reading package lists... Done
Building dependency tree      
Reading state information... Done
The following NEW packages will be installed:
  v4l-conf
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Inst v4l-conf (3.102-3 Debian:7.3/stable [amd64])
Conf v4l-conf (3.102-3 Debian:7.3/stable [amd64])

wiz@cb-DOC:~/Downloads$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 002 Device 002: ID 8087:0020 Intel Corp. Integrated Rate Matching Hub
Bus 001 Device 003: ID 0402:9665 ALi Corp. Gateway Webcam
Bus 002 Device 003: ID 0489:e011 Foxconn / Hon Hai

wiz@cb-DOC:~$ vlc v4l:// --> use the v4l protocol to watch the live stream off your webcam.
VLC media player 2.0.3 Twoflower (revision 2.0.2-93-g77aa89e)
[0x10b3108] main libvlc: Running vlc with the default interface. Use 'cvlc' to use vlc without interface.

Voila... you can now see your webcam in action.. Smile :)

more info:---> http://packages.debian.org/squeeze/libv4l-0

Install FTP client FileZilla on Debian

Lets go about installing filezilla, if you fancy a seamless drag and drop functionality connection from your GUI enabled host to your remote server. 

wiz@cb-DOC:~/.ssh$ sudo apt-cache search filezilla
[sudo] password for wiz:
filezilla - Full-featured graphical FTP/FTPS/SFTP client
filezilla-common - Architecture independent files for filezilla

wiz@cb-DOC:~/.ssh$ sudo apt-get install filezilla
Reading package lists... Done
Building dependency tree    
Reading state information... Done
The following extra packages will be installed:
  filezilla-common libtinyxml2.6.2
The following NEW packages will be installed:
  filezilla filezilla-common libtinyxml2.6.2
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 4,324 kB of archives.
After this operation, 11.3 MB of additional disk space will be used.
Do you want to continue [Y/n]? y
Get:1 http://http.debian.net/debian/ wheezy/main libtinyxml2.6.2 amd64 2.6.2-1 [43.8 kB]
Get:2 http://http.debian.net/debian/ wheezy/main filezilla-common all 3.5.3-2 [3,015 kB]
Get:3 http://http.debian.net/debian/ wheezy/main filezilla amd64 3.5.3-2 [1,265 kB]
Fetched 4,324 kB in 34s (126 kB/s)                                        
Selecting previously unselected package libtinyxml2.6.2.
(Reading database ... 221226 files and directories currently installed.)
Unpacking libtinyxml2.6.2 (from .../libtinyxml2.6.2_2.6.2-1_amd64.deb) ...
Selecting previously unselected package filezilla-common.
Unpacking filezilla-common (from .../filezilla-common_3.5.3-2_all.deb) ...
Selecting previously unselected package filezilla.
Unpacking filezilla (from .../filezilla_3.5.3-2_amd64.deb) ...
Processing triggers for man-db ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for menu ...
Processing triggers for desktop-file-utils ...
Setting up libtinyxml2.6.2 (2.6.2-1) ...
Setting up filezilla-common (3.5.3-2) ...
Setting up filezilla (3.5.3-2) ...
Processing triggers for menu ...

Wednesday, May 14, 2014

Lvm extend on Linux

Below is a flow of sequence 

[root@pc-DOC ~]# fdisk /dev/sda 

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM

Command (m for help): n
Command action
e extended
p primary partition (1-4)
e
Selected partition 4
First cylinder (39163-52216, default 39163): 
Using default value 39163
Last cylinder, +cylinders or +size{K,M,G} (39163-52216, default 52216): 
Using default value 52216

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 5 Extended

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): t
Partition number (1-5): 4
Hex code (type L to list codes): 8e
You cannot change a partition into an extended one or vice versa
Delete it first.

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 5 Extended

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 5 Extended

Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)

Command (m for help): d
Partition number (1-5): 4

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM

Command (m for help): n
Command action
e extended
p primary partition (1-4)
p

Command (m for help): p

Disk /dev/sda: 429.5 GB, 429496729600 bytes
255 heads, 63 sectors/track, 52216 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00005b0f

Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 13055 104344576 8e Linux LVM
/dev/sda3 13055 39163 209715200 8e Linux LVM
/dev/sda4 39163 52216 104852220 83 Linux

Command (m for help): t
Partition number (1-4): 4
Hex code (type L to list codes): 8e
Changed system type of partition 4 to 8e (Linux LVM)


Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

[root@pc-Doc ~]# ls /dev/sda
sda sda1 sda2 sda3 sda4 

Last login: Thu Jan 23 23:39:15 2014 from 10.253.11.14
[root@pc-Doc ~]# ls /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# ls /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# ls /dev/sda4
/dev/sda4
[root@pc-Doc ~]# pvdisplay 
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_pc-Doc
PV Size 99.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25474
Free PE 0
Allocated PE 25474
PV UUID 2kMDWt-8cjq-WJKd-ThqQ-rzLF-2CC2-UwnYID

--- Physical volume ---
PV Name /dev/sda3
VG Name vg_pc-Doc
PV Size 200.00 GiB / not usable 4.00 MiB
Allocatable yes 
PE Size 4.00 MiB
Total PE 51199
Free PE 321
Allocated PE 50878
PV UUID 8a2FHr-MHsf-x1vu-sbcg-iBX0-chWA-NE9f7X

[root@pc-Doc ~]# pvcreate -f /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# pvcreate -f /dev/sda
sda sda1 sda2 sda3 sda4 
[root@pc-Doc ~]# pvcreate -f /dev/sda4
Physical volume "/dev/sda4" successfully created
[root@pc-Doc ~]# pvdisplay 
--- Physical volume ---
PV Name /dev/sda2
VG Name vg_pc-Doc
PV Size 99.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 25474
Free PE 0
Allocated PE 25474
PV UUID 2kMDWt-8cjq-WJKd-ThqQ-rzLF-2CC2-UwnYID

--- Physical volume ---
PV Name /dev/sda3
VG Name vg_pc-Doc
PV Size 200.00 GiB / not usable 4.00 MiB
Allocatable yes 
PE Size 4.00 MiB
Total PE 51199
Free PE 321
Allocated PE 50878
PV UUID 8a2FHr-MHsf-x1vu-sbcg-iBX0-chWA-NE9f7X

"/dev/sda4" is a new physical volume of "99.99 GiB"
--- NEW Physical volume ---
PV Name /dev/sda4
VG Name 
PV Size 99.99 GiB
Allocatable NO
PE Size 0 
Total PE 0
Free PE 0
Allocated PE 0
PV UUID uuAtBs-gAVd-WHv0-7stJ-C3Ed-LVwK-HEc2zM

[root@pc-Doc ~]# vgdisplay 
--- Volume group ---
VG Name vg_pc-Doc
System ID 
Format lvm2
Metadata Areas 2
Metadata Sequence No 10
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 299.50 GiB
PE Size 4.00 MiB
Total PE 76673
Alloc PE / Size 76352 / 298.25 GiB
Free PE / Size 321 / 1.25 GiB
VG UUID AQ59Um-Lsse-N0xS-gfoc-cHCR-AL0r-1HSgia

[root@pc-Doc ~]# vgextend vg_pc-Doc /dev/sda4
Volume group "vg_pc-Doc" successfully extended
[root@pc-Doc ~]# vgdisplay 
--- Volume group ---
VG Name vg_pc-Doc
System ID 
Format lvm2
Metadata Areas 3
Metadata Sequence No 11
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 3
Act PV 3
VG Size 399.50 GiB
PE Size 4.00 MiB
Total PE 102271
Alloc PE / Size 76352 / 298.25 GiB
Free PE / Size 25919 / 101.25 GiB
VG UUID AQ59Um-Lsse-N0xS-gfoc-cHCR-AL0r-1HSgia

[root@pc-Doc ~]# lvdisplay 
--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_root
LV Name lv_root
VG Name vg_pc-Doc
LV UUID so0YcW-rveL-SDsI-ipVF-JhrR-eUG4-d9yB1g
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:26 -0500
LV Status available
# open 1
LV Size 290.20 GiB
Current LE 74290
Segments 3
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_swap
LV Name lv_swap
VG Name vg_pc-Doc
LV UUID hmD6Yj-m4qE-a422-rGLG-qk3l-TCdk-bOQnAk
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:47 -0500
LV Status available
# open 1
LV Size 8.05 GiB
Current LE 2062
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

[root@pc-Doc ~]# lvextend -L +100G /dev/vg_pc-Doc/lv_root
Extending logical volume lv_root to 390.20 GiB
Logical volume lv_root successfully resized
[root@pc-Doc ~]# lvdisplay 
--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_root
LV Name lv_root
VG Name vg_pc-Doc
LV UUID so0YcW-rveL-SDsI-ipVF-JhrR-eUG4-d9yB1g
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:26 -0500
LV Status available
# open 1
LV Size 390.20 GiB
Current LE 99890
Segments 4
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0

--- Logical volume ---
LV Path /dev/vg_pc-Doc/lv_swap
LV Name lv_swap
VG Name vg_pc-Doc
LV UUID hmD6Yj-m4qE-a422-rGLG-qk3l-TCdk-bOQnAk
LV Write Access read/write
LV Creation host, time pc-Doc, 2013-08-24 17:04:47 -0500
LV Status available
# open 1
LV Size 8.05 GiB
Current LE 2062
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1

[root@pc-Doc ~]# resize2fs /dev/vg_pc-Doc/lv_root^C
[root@pc-Doc ~]# df -hT /dev/vg_pc-Doc/lv_root
Filesystem Type Size Used Avail Use% Mounted on
- - 7.8G 172K 7.8G 1% /dev
[root@pc-Doc ~]# df -hT / 
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_pc-Doc-lv_root
ext4 286G 201G 71G 75% /
[root@pc-Doc ~]# resize2fs /dev/vg_pc-Doc/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/vg_pc-Doc/lv_root is mounted on /; on-line resizing required
old desc_blocks = 19, new_desc_blocks = 25
Performing an on-line resize of /dev/vg_pc-Doc/lv_root to 102287360 (4k) blocks.
The filesystem on /dev/vg_pc-Doc/lv_root is now 102287360 blocks long.

[root@pc-Doc ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/vg_pc-Doc-lv_root
ext4 385G 201G 164G 56% /
tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/sda1 ext4 485M 64M 396M 14% /boot
[root@pc-Doc ~]#

Configure SFTP password-less asymmetric key exchange


Creating sftpusers group and adding users into this group

root@SFTP-Server:~# groupadd sftpusers
root@SFTP-Server:~# useradd -G sftpusers -d /home/sftpadmin/ -s /bin/false sftpadmin
root@SFTP-Server:~# chgrp -R sftpusers /home/sftpadmin
root@SFTP-Server:~# chown sftpadmin:sftpusers /home/sftpadmin
root@SFTP-Server:~# chown -R sftpadmin:sftpusers /home/sftpadmin/
root@SFTP-Server:~# chmod 750 /home/sftpadmin

Confirm it as follows:
root@SFTP-Server:~# ls -lhd /home/sftpadmin
drwxr-x--- 4 sftpadmin sftpusers 4.0K Jan 13 09:21 /home/sftpadmin

Now,Create a director .ssh and copy the public key to authorized_keys under the /home/sftpadmin/.ssh/

root@SFTP-Server:~# chmod 700 /home/sftpadmin/.ssh
root@SFTP-Server:~# chmod 600 /home/sftpadmin/.ssh/authorized_keys

Copy the public key to the SFTP-Server
root@SFTP-Server:~# cat /home/sftpadmin/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAIEAiy3mJTHkS74taR3spRkbZJhgz4CjSHKsMmPDPRA6cbA1Tkd3BEitAs7ofB7Tlv6+WlMXeuq1V9gy4muF9pSWJuEjzDreULD3mlbjY40jvrYXMZZHdOVfm9J93QcTJChfwmJe5gYyVwp5N2Hyt40f
Make sure there are no extra spaces at the end of the public key

Now execute the below command to complete the permissions
root@SFTP-Server:~# chown -R sftpadmin:sftpusers /home/sftpadmin/

Now change /etc/ssh/sshd_config and comment out sftp-server line and add a new line Subsystem sftp internal-sftp as follows:

root@SFTP-Server:~# vi /etc/ssh/sshd_config
# override default of no subsystems
#Subsystem sftp /usr/libexec/openssh/sftp-server
Subsystem sftp internal-sftp

The configuration is now Done, Confirm by accessing from winscp be providing the private key

To cross verify, Within the /var/log/secure logs we should see the similar messages

Jan 13 01:56:59 cent59-02 sshd[6793]: Accepted publickey for sftpadmin from 172.22.101.217 port 1539 ssh2
Jan 13 01:56:59 cent59-02 sshd[6793]: pam_unix(sshd:session): session opened for user sftpadmin by (uid=0)


=============================

wiz@cb-DOC:~$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/wiz/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/wiz/.ssh/id_rsa.
Your public key has been saved in /home/wiz/.ssh/id_rsa.pub.
The key fingerprint is:
7f:0b:98:5b:5b:7c:c4:32:a0:c6:31:d7:78:5e:dd:68 wiz@cb-DOC
The key's randomart image is:
+--[ RSA 2048]----+
|                 |
|             o .o|
|          o + E +|
|         . ==. = o |
|        S +   + o|
|         o o . + |
|          == o o .|
|           = + . |
|          . o    |
+-----------------+
wiz@cb-DOC:~$


AAAAB3NzaC1yc2EAAAADAQABAAABAQDQazG6pBU5hBcuPsEg0kwXaCq2KiSdMbWT9HvEFFc8Leb3VbmwfZwSJv5SDd36Zm8x0a8BYnMYW/BZ9fO5z5WdK7lfKCtFLf93T1x3AuwPRk8zJKLJFD7AH7Hw/9IO2Q6fzFQTFnYIMETOpy+SZSCaXkdpGFdkXt3qFw5rXKfd02T2iaHtzhMSp/uevGqQsUmfQB50exgj+SZyzeupibqOaRwQGZGj55iRrsdIVETUXTFFvbiYAJWjD9Wi9KDXMR11XZtDwzYr37kHFl9MaxOx2ktl7avfMDE1scUOoFhtZod/DRI5b6AC9zR4BFvPPGBPoFf


ssh-copy-id -i .ssh/id_dsa.pub root@192.168.1.4
 1247  ssh root@192.168.1.4


root@ubuntu-v12:~# cat /home/sftpadmin/.ssh/authorized_keys
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDQazG6pBU5hBcuPsEg0kwXaCq2KiSdMbWT9HvEFFc8Leb3VbmwfZwSJv5SDd36Zm8x0a8BYnMYW/BZ9fO5z5WdK7lfKCtFLf93T1x3AuwPRk8zJKLJFD7AH7Hw/9IO2Q6fzFQTFnYIMETOpy+SZSCaXkdpGFdkXt3qFw5rXKfd02T2iaHtzhMSp/uevGqQsUmfQB50exgj+SZyzeupibqOaRwQGZGj55iRrsdIVETUXTFFvbiYAJWjD9Wi9KDXMR11XZtDwzYr37kHFl9MaxOx2ktl7avfMDE1scUOoFhtZod/DRI5b6AC9zR4BFvPPGBPoFf
root@ubuntu-v12:~#

root@ubuntu-v12:~# ls -lthd  /home/sftpadmin/*
drwxr-x--- 3 sftpadmin sftpadmin 4.0K Jan 13 22:01 /home/sftpadmin/public
root@ubuntu-v12:~# ls -lthd  /home/sftpadmin/
drwxr-x--- 5 sftpadmin sftpusers 4.0K Jan 13 21:32 /home/sftpadmin/
root@ubuntu-v12:~# ls -lthd  /home/
drwxr-xr-x 4 root root 4.0K Jan 13 19:36 /home/

Note, the home folder for the new sftp user has to be given root owner.s

cat /etc/ssh/sshd_config
Subsystem sftp internal-sftp
UsePAM yes
Match Group sftpuser
        ChrootDirectory %h
        ForceCommand internal-sftp


wiz@ubuntu-v12:~$ grep sftpadmin /etc/passwd
sftpadmin:x:1001:1002::/home/sftpadmin/:/bin/false

view /var/log/auth.log
Jan 13 23:20:14 ubuntu-v12 sshd[6372]: Accepted publickey for sftpadmin from 192.168.1.2 port 58409 ssh2
Jan 13 23:20:14 ubuntu-v12 sshd[6372]: pam_unix(sshd:session): session opened for user sftpadmin by (uid=0)
Jan 13 23:20:15 ubuntu-v12 sshd[6514]: subsystem request for sftp by user sftpadmin
Jan 13 23:21:02 ubuntu-v12 sshd[6516]: Accepted password for wiz from 192.168.1.2 port 58410 ssh2
Jan 13 23:21:02 ubuntu-v12 sshd[6516]: pam_unix(sshd:session): session opened for user wiz by (uid=0)

apt-get update public key unavailable error

root@ubuntu1204:~# apt-get upgrade --simulate
Reading package lists... Done
Building dependency tree
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@ubuntu1204:~# apt-get update --simulate
Ign http://extras.ubuntu.com precise InRelease
Ign http://in.archive.ubuntu.com precise InRelease
Get:1 http://extras.ubuntu.com precise Release.gpg [72 B]
Hit http://in.archive.ubuntu.com precise Release.gpg
Hit http://in.archive.ubuntu.com precise Release
Hit http://extras.ubuntu.com precise Release
Ign http://extras.ubuntu.com precise Release
Hit http://in.archive.ubuntu.com precise/main Sources
Ign http://extras.ubuntu.com precise/main Sources/DiffIndex
Ign http://archive.canonical.com precise InRelease
Hit http://in.archive.ubuntu.com precise/restricted Sources
Ign http://extras.ubuntu.com precise/main i386 Packages/DiffIndex
Hit http://in.archive.ubuntu.com precise/universe Sources
Ign http://extras.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise/multiverse Sources
Hit http://extras.ubuntu.com precise/main Sources
Hit http://in.archive.ubuntu.com precise/main i386 Packages
Hit http://archive.canonical.com precise Release.gpg
Hit http://extras.ubuntu.com precise/main i386 Packages
Hit http://in.archive.ubuntu.com precise/restricted i386 Packages
Hit http://in.archive.ubuntu.com precise/universe i386 Packages
Hit http://in.archive.ubuntu.com precise/multiverse i386 Packages
Hit http://archive.canonical.com precise Release
Hit http://in.archive.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise/multiverse TranslationIndex
Hit http://in.archive.ubuntu.com precise/restricted TranslationIndex
Hit http://in.archive.ubuntu.com precise/universe TranslationIndex
Hit http://archive.canonical.com precise/partner Sources
Hit http://in.archive.ubuntu.com precise/main Translation-en
Hit http://in.archive.ubuntu.com precise/multiverse Translation-en
Ign http://extras.ubuntu.com precise/main Translation-en_US
Hit http://in.archive.ubuntu.com precise/restricted Translation-en
Hit http://archive.canonical.com precise/partner i386 Packages
Ign http://extras.ubuntu.com precise/main Translation-en
Hit http://in.archive.ubuntu.com precise/universe Translation-en
Ign http://archive.canonical.com precise/partner TranslationIndex
Ign http://archive.canonical.com precise/partner Translation-en_US
Ign http://archive.canonical.com precise/partner Translation-en
Fetched 72 B in 8s (8 B/s)
Reading package lists... Done
W: GPG error: http://extras.ubuntu.com precise Release: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 16126D3A3E5C1192

Now follow and execute the gpg commands by fetching the key from the ubuntu.

root@ubuntu1204:~# gpg --keyserver keyserver.ubuntu.com --recv 3E5C1192
gpg: directory `/root/.gnupg' created
gpg: new configuration file `/root/.gnupg/gpg.conf' created
gpg: WARNING: options in `/root/.gnupg/gpg.conf' are not yet active during this run
gpg: keyring `/root/.gnupg/secring.gpg' created
gpg: keyring `/root/.gnupg/pubring.gpg' created
gpg: requesting key 3E5C1192 from hkp server keyserver.ubuntu.com
gpg: /root/.gnupg/trustdb.gpg: trustdb created
gpg: key 3E5C1192: public key "Ubuntu Extras Archive Automatic Signing Key <ftpmaster@ubuntu.com>" imported
gpg: no ultimately trusted keys found
gpg: Total number processed: 1
gpg:               imported: 1
root@ubuntu1204:~# gpg --export --armor 3E5C1192 | apt-key add -
OK

Now do an update.. and we are fine.
root@ubuntu1204:~# apt-get update --simulate
Ign http://extras.ubuntu.com precise InRelease
Get:1 http://extras.ubuntu.com precise Release.gpg [72 B]
Ign http://in.archive.ubuntu.com precise InRelease
Hit http://extras.ubuntu.com precise Release
Ign http://archive.canonical.com precise InRelease
Hit http://extras.ubuntu.com precise/main Sources
Hit http://in.archive.ubuntu.com precise Release.gpg
Hit http://extras.ubuntu.com precise/main i386 Packages
Ign http://extras.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise Release
Hit http://archive.canonical.com precise Release.gpg
Hit http://in.archive.ubuntu.com precise/main Sources
Hit http://archive.canonical.com precise Release
Hit http://in.archive.ubuntu.com precise/restricted Sources
Hit http://archive.canonical.com precise/partner Sources
Hit http://in.archive.ubuntu.com precise/universe Sources
Ign http://extras.ubuntu.com precise/main Translation-en_US
Hit http://in.archive.ubuntu.com precise/multiverse Sources
Ign http://extras.ubuntu.com precise/main Translation-en
Hit http://archive.canonical.com precise/partner i386 Packages
Hit http://in.archive.ubuntu.com precise/main i386 Packages
Ign http://archive.canonical.com precise/partner TranslationIndex
Hit http://in.archive.ubuntu.com precise/restricted i386 Packages
Hit http://in.archive.ubuntu.com precise/universe i386 Packages
Hit http://in.archive.ubuntu.com precise/multiverse i386 Packages
Hit http://in.archive.ubuntu.com precise/main TranslationIndex
Hit http://in.archive.ubuntu.com precise/multiverse TranslationIndex
Hit http://in.archive.ubuntu.com precise/restricted TranslationIndex
Hit http://in.archive.ubuntu.com precise/universe TranslationIndex
Hit http://in.archive.ubuntu.com precise/main Translation-en
Hit http://in.archive.ubuntu.com precise/multiverse Translation-en
Hit http://in.archive.ubuntu.com precise/restricted Translation-en
Hit http://in.archive.ubuntu.com precise/universe Translation-en
Ign http://archive.canonical.com precise/partner Translation-en_US
Ign http://archive.canonical.com precise/partner Translation-en
Fetched 72 B in 7s (10 B/s)

HTH