Login to LINUX / Unix box using SSH without password

Here is a mini HOWTO to SSH onto a UNIX Box without typing password.

Server: LINUXSERVER (user –> linuxuser)
Client: iMAC ( user –> demouser)

  • Generate Authentication keys using ssh-keygen on client
$ ssh-keygen -t rsa 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/demouser/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/demouser/.ssh/id_rsa.
Your public key has been saved in /home/demouser/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx demouser@iMAC
The key’s randomart image is:
+–[ RSA 2048]—-+
+—————–+
  • Copy the id_rsa.pub to server onto $HOME_DIR/.ssh/authorized_keys2
  • Setup a symbolic link to authorized_keys
          ln -s authorized_keys2 authorized_keys
  • chmod 0600 on authorized_keys2 & authorized_keys file
Testing 
  • From the client try ssh linuxuser@linuxserver, ssh shouldn’t ask for password. 

Disallow direct root logins via SSH

Permitting root login via SSH poses high risk, so its recommended to disable root login authentication via SSH.

Edit /etc/ssh/sshd_config and set the “PermitRootLogin” as “no”. This will stop root login from using SSH.

Note: Ensure you have another ID setup to access the UNIX box, else you would be in trouble to reach the box.

Howto resize an ext4 partition

CAUTION: While resizing the partition there is always some risk of data loss, so ensure you have backed up all data before you follow this guide.

Shrink a Partition:



Here i will explain how a single partition 80G disk has been broken into 50 / 1 / 29

$ sudo fdisk /dev/sda

The number of cylinders for this disk is set to 9729.

There is nothing wrong with that, but this is larger than 1024,

and could in certain setups cause problems with:

1) software that runs at boot time (e.g., old versions of LILO)

2) booting and partitioning software from other OSs

(e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): p

Disk /dev/sda: 80.0 GB, 80026361856 bytes

255 heads, 63 sectors/track, 9729 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System

/dev/sda1 1 9729 78148161 83 Linux





$ sudo resize2fs /dev/sda1 49G
resize2fs 1.41.4 (27-Jan-2009)
Resizing the filesystem on /dev/sda1 to 12845056 (4k) blocks.
The filesystem on /dev/sda1 is now 12845056 blocks long.
Use CFDISK to
  • delete the partition (with size 80G)
  • re-create a new partition with sizes 52G
$ sudo cfdisk /dev/sda
Use resize2fs on the new partition
$ sudo resize2fs /dev/sda1
resize2fs 1.41.4 (27-Jan-2009)
Resizing the filesystem on /dev/sda1 to 12695358 (4k) blocks.
The filesystem on /dev/sda1 is now 12695358 blocks long.



NOTE: If partition size is lesser than filesystem size then you will see an error as shown below. Use cfdisk and recreate the partition.


$ sudo resize2fs /dev/sda1
resize2fs 1.41.4 (27-Jan-2009)
Resizing the filesystem on /dev/sda1 to 12450367 (4k) blocks.
resize2fs: Can’t read an block bitmap while trying to resize /dev/sda1


mount and the new partition to confirm data exists

$ sudo mount /dev/sda1 /media/
$ cd /media/
$ ls
lost+found www
$ ls -alrt
total 16
drwxr-xr-x 4 root root 4096 Dec 26 08:28 .
drwxrwxrwx 3 www-data www-data 4096 Dec 26 08:33 www
drwxrwxr-x 21 root root 4096 Dec 26 08:38 ..
drwx—— 2 root root 4096 Dec 26 11:52 lost+found
$ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/mmcblk0p1 1889792 894844 898952 50% /
tmpfs 256648 0 256648 0% /lib/init/rw
varrun 256648 284 256364 1% /var/run
varlock 256648 0 256648 0% /var/lock
udev 256648 120 256528 1% /dev
tmpfs 256648 0 256648 0% /dev/shm
tmpfs 256648 26592 230056 11% /var/cache/apt
/dev/sda1 49983444 240488 47203888 1% /media





Sheevaplug ping problem

After doing a apt-get update / upgrade and reboot, ping command doesn’t work anymore. A quick change mode on /bin/ping will resolve this problem

$ ping google.com
ping: icmp open socket: Operation not permitted
$ ls -lart /bin/ping
-rwxr-xr-x 1 root root 34948 Nov 14 2008 /bin/ping
$ sudo chmod u+s /bin/ping
$ ls -lart /bin/ping
-rwsr-xr-x 1 root root 34948 Nov 14 2008 /bin/ping
$ !ping
ping google.com
PING google.com (66.249.89.104) 56(84) bytes of data.
64 bytes from nrt04s01-in-f104.1e100.net (66.249.89.104): icmp_seq=1 ttl=50 time=8.05 ms
64 bytes from nrt04s01-in-f104.1e100.net (66.249.89.104): icmp_seq=2 ttl=51 time=7.66 ms

Kurosheeva / Sheevaplug uboot

Connect USB cable to mini USB port on the sides of Kurosheeva device.
Fire up the serial communication interface using Teraterm / screen (in osx).
screen /dev/tty.usbserial-FTTI0TO6B 115200
Switch-on your device and following output can be seen on the terminal
__ __ _ _
| / | __ _ _ ____ _____| | |
| |/| |/ _` | ‘__ / / _ | |
| | | | (_| | | V / __/ | |
|_| |_|__,_|_| _/ ___|_|_|
_ _ ____ _
| | | | | __ ) ___ ___ | |_
| | | |___| _ / _ / _ | __|
| |_| |___| |_) | (_) | (_) | |_
___/ |____/ ___/ ___/ __|
** MARVELL BOARD: SHEEVA PLUG LE


U-Boot 1.1.4 (Jul 14 2009 – 06:46:57) Marvell version: 3.4.16


U-Boot code: 00600000 -> 0067FFF0 BSS: -> 006CF120


Soc: 88F6281 A0 (DDR2)
CPU running @ 1200Mhz L2 running @ 400Mhz
SysClock = 400Mhz , TClock = 200Mhz


DRAM CAS Latency = 5 tRP = 5 tRAS = 18 tRCD=6
DRAM CS[0] base 0x00000000 size 256MB
DRAM CS[1] base 0x10000000 size 256MB
DRAM Total size 512MB 16bit width
Flash: 0 kB
Addresses 8M – 0M are saved for the U-Boot usage.
Mem malloc Initialization (8M – 7M): Done
NAND:512 MB


CPU : Marvell Feroceon (Rev 1)


Streaming disabled
Write allocate disabled




USB 0: host mode
PEX 0: interface detected no Link.
Net: egiga0 [PRIME], egiga1
Hit any key to stop autoboot: 0
Marvell>>


Marvell>> printenv
baudrate=115200
loads_echo=0
ipaddr=10.4.50.165
serverip=10.4.50.5
rootpath=/mnt/ARM_FS/
netmask=255.255.255.0
console=console=ttyS0,115200 mtdparts=nand_mtd:0xc0000@0(uboot)ro,0x1ff00000@0x100000(root)
CASset=min
MALLOC_len=1
ethprime=egiga0
bootargs_root=root=/dev/nfs rw
bootargs_end=:::DB88FXX81:eth0:none
image_name=uImage
standalone=fsload 0x2000000 $(image_name);setenv bootargs $(console) root=/dev/mtdblock0 rw ip=$(ipaddr):$(serverip)$(bootargs_end) $(mvPhoneConfig); bootm 0x2000000;
ethmtu=1500
mvPhoneConfig=mv_phone_config=dev0:fxs,dev1:fxs
mvNetConfig=mv_net_config=(00:XX:XX:XX:XX:XX,0:1:2:3),mtu=1500
usb0Mode=host
yuk_ethaddr=00:00:00:XX:XX:XX
nandEcc=1bit
netretry=no
rcvrip=169.254.100.100
loadaddr=0x02000000
autoload=no
ethact=egiga0
ethaddr=XX:XX:XX
run_diag=no
bootargs=console=ttyS0,115200 mtdparts=nand_mtd:0x400000@0x100000(uImage),0x1fb00000@0x500000(rootfs) rw root=/dev/mtdblock1 rw ip=10.4.50.4:10.4.50.5:10.4.50.5:255.255.255.0:XXXXXXXXXX
:eth0:none
bootcmd=nand read.e 0x800000 0x100000 0x400000; bootm 0x800000
stdin=serial
stdout=serial
stderr=serial
mainlineLinux=no
enaMonExt=no
enaCpuStream=no
enaWrAllo=no
pexMode=RC
disL2Cache=no
setL2CacheWT=yes
disL2Prefetch=yes
enaICPref=yes
enaDCPref=yes
sata_dma_mode=yes
netbsd_en=no
vxworks_en=no
bootdelay=3
disaMvPnp=no
enaAutoRecovery=yes
Environment size: 1330/131068 bytes
Marvell>>