Wednesday, 20 June 2012

SFTP access to Fedora VM (vmware)

Recently we're asked to set up a new OS in VMware and grant FTP access (for onsite and offsite both). FTP was widely used for such requests however it had one major flaw. All data including login details were transmitted in plain text. So do avoid the malicious activity / attack, FTPS was introduced. It is basically FTP Protocol with added encryption using SSL. However, it still works on FTP protocol. 

There is a new and better technique used now a days called SFTP. It is a subsystem of SSH protocol. What is interesting is it does not use FTP in any way nor does it require any kind of FTP software (like vsftpd) for it to function.




However, in order to use SFTP you must have OpenSSH version 5 or newer installed. You can find you ssh version by -  
$ ssh -V
OpenSSH_5.8p2, OpenSSL 1.0.0j-fips 10 May 2012


With the basic implementation of SSH if a user logs in they are dropped in their home directory. With a few basic commands (cd /) they can back out of their home directory and into the root directory. To stop this and confine a user to their home directory we chroot the user. The act of locking or confining a user to a certain directory is called chroot or chrooting, which means "to change the root directory". Chrooting a user will for all intents and purposes change their root directory to their home directory. They will not be able to back out of the directory.

To begin we will need to edit the /etc/ssh/sshd_config and set the following options:
$ vi /etc/ssh/sshd_config
Subsystem sftp internal-sftp
Match Group sftp
ChrootDirectory %h
ForceCommand internal-sftp
AllowTcpForwarding no

Now let's create the sftp group, create a user, create a password for that user and add them to the sftp group.
$ groupad sftp
$ useradd nitish
$ passwd nitish
$ usermod -G sftp nitish
$ id nitish
uid=502(nitish) gid=502(nitish) groups=502(nitish),503(sftp)

Now, we need to take away the shell access for user "nitish" so he can only SFTP and SCP.
$ usermod -s /bin/false nitish

Now, lock the user "nitish" into his home directory. Change the ownership of their home directory to root and set permissions.
$ chown root:root /home/nitish
$ chmod 0755 /home/nitish

Above dir. modifications are required for a secure chroot. But this limits what user "nitish" can do, for example with the current setup the user "nitish" will be able to log in, but not be able to create a directory or upload any files. So now make a new directory inside this user "nitish" home directory which is owned by him.
$ mkdir /home/nitish/nitish_directory
$ chown nitish /home/nitish/nitish_directory

The above command will allow the user "nitish" Full access to "nitish_directory" to upload, download, and create more directories inside. But it will also limit access to his home directory (which becomes his root directory).

All Done!!!!

Tuesday, 10 April 2012

VMware Tools on Fedora.


This is a step by step guide for installing vmwaretools on Fedora (I am using version 16) 64 bit (i686). 

#Choose VM > Install VMware Tools.

Open a Terminal Session:

[nish@test-box]# yum install kernel-devel gcc gcc-c++ kernel-PAE-devel
[nish@test-box]# yum update
[nish@test-box]# mkdir /mnt/cdrom                           (this creates a mount directory)
[nish@test-box]# mount /dev/cdrom /mnt/cdrom   (this mounts the cdrom)
[nish@test-box]# tar zxpf /mnt/cdrom/VMwareTools-5.0.0-.tar.gz      
#Where  is the build/revision number of the VMware Workstation release.
[nish@test-box]# umount /dev/cdrom                                             
[nish@test-box]# cd vmware-tools-distrib
[nish@test-box]# ./vmware-install.pl

After this just follow default options. In some *NIX versions you might come across an error where it asks you about the location of the C directory header files that match your running kernel. By default this looks like:

[/usr/src/linux/include]    -  however this doesn't exist. Therefore, you will need to do the following tweak for it to work successfully.

use this instead:-
/usr/src/kernels/'uname -r'/include

Then you might see this error:-
The directory of kernel headers (version @@VMWARE@@ UTS_RELEASE) does not match
your running kernel (version x.x.xx.x-xxx.fcxx.x86_64). Even if the module
were to compile successfully, it would not load into the running kernel.


Open another Terminal session:

[nish@test-box]# cd /usr/src/kernels/x.x.xx.x-xxx.fcxx.x86_64/include
[nish@test-box]# find . -iname '*relea*'
./config/kernel.release
./generate/utsrelease.h
[nish@test-box]# sudo cp -p generated/utsrelease.h linux/

Go back to the first Terminal session:

What is location of the directory of C header files that match your running kernel? [/usr/src/linux/include] /usr/src/kernels/'uname -r'/include

It will now extract the sources of the vmmemctl module. Bingo, the installation proceeds smoothly now. It would ask you to create few directory which doesn't exist  (just choose the default options). 

Hope this helps people having trouble installing VMwareTools on Fedora.


Wednesday, 25 January 2012

Netwok Switches


This is a step by step guide for configuring a HP Pro-Curve Switch. Currently, HP offers Life-time warranty for all its products (until unless it is physically damaged).
Set-up procedure for HP Pro-curve 2600

SWITCH (setting configuration for switch):-
1.     Find an internal fixed IP for the n/w switch.
2.     Power on the Switch. Find a Serial Cable. Find a PC.
3.     Connect the Switch to PC through the Serial Port.
4.     Putty - Serial.
5.     Type menu (you might have to hit enter 2-3 times).
6.     Switch Configuration – IP config.
7.     Assign a fixed IP (from step:1) to the switch. Change DHCP to Manual (using the spacebar).
8.     Gateway – 192.168.xxx.xxx  and  Subnet – 255.255.255.0

PC (settings configuration for access):-
1.     Now go to a web browser and type the IP (from step 1).
2.     Disable Stacking (Configuration - Stacking - Disable).
3.     Set login details (Security - read/write)
4.     Name the switch (System Info - Name - Building_Room_SwitchNameType).
     
       DNS (make a DNS entry for the switch):
       RDP to DC - select DNS - Forward lookup - FQDN - right click and select New Host - Name - Building_Room_SwitchNameType.


      HP Procurve Server (setting configuration for networking monitoring s/w):-
1.     RDP to Server - Procurve Manager - administrator (root passwd)
2.     Tools - Manual Discovery - IP (from step 1 in SWITCH).
3.     Right click on the switch IP and select re-discover.
4.     S/w version (Right click - s/w update) – it will ask whether you want to upgrade primary and secondary version (in the flash buffer) or both. If the switch is a core switch then always select one (either pri or sec). This is because if something goes wrong after update and reboot then we can always roll back to the previous version (through either pri or sec). Other general switches - select to upgrade all (both primary and secondary versions). 

Friday, 18 June 2010

Network Troubleshooting

Last Wednesday we had a major network issue. The story started from end-users calling our help-desk and soon there was a chaos in the department because of the increasing number of phone calls. Soon users spread the news among themselves and we confirmed the whole site is experiencing networking issues.

We spent almost 5 hours sorting out the problem, however I will only mention the steps anyone should be taking in this scenario to cut the long story short.

1. First thing first always check whether you can connect to the core switches on the site. In our case we had 2 core switches and one went down because of a faulty port on the switch (in our case it was F11). It does sound very easy however it was a nightmare for us to get to this information because we couldn't even login to the switch. We had to connect and log-in to the other core switch and find the faulty port from there.

2. Second thing to look for is the DNS. Reboot your DNS server and it fixes the problem 5 out of 10 times.