Start eth0 on boot

24 12 2011

Hey all, while checking some setups from my Linux CentOS 6, it came to my mind how boring is to remember simple steps to start my eth0 so I can access my machine remotely.

To do that simply start the service as root first

# ifup eth0

Once you have your network working edit the ifcfg-eth0 file located on /etc/sysconfig/network-scripts (note that this path may change in different Linux distributions)

Change the ONBOOT=”no” to ONBOOT=”yes”

restart the system and it’s done.

Obs. It should work with any eth*.





Installing Gcc / Automake / Perl/ Python and Others on Linux Red Hat / CentOS

3 12 2011

Most of the software binaries requires the installation of several libraries in Linux, the top required are Gcc and Make.

To have all of them downloaded and installed at once simply download the Development Tools group using the yum command line.

$ yum groupinstall ‘Development Tools’

The command line above will install the following libs

  • flex
  • redhat-rpm-config
  • strace
  • gcc
  • pkgconfig
  • gettext
  • make
  • strace64
  • rpm-build
  • gcc-c++
  • automake
  • gdb
  • bison
  • libtool
  • autoconf
  • binutils and all dependencies

I hope that works for you as well.





Start FTP Server on Linux/AIX

21 01 2010

Through this post I’d like to share with you how to start a simple FTP server on Linux/AIX.

Go to /etc/vsftpd/ and open file vsftpd.conf. There are several parameter you could set according your needs.

Parameter connect_from_port_20 should be set to YES.

Run /etc/init.d/vsftpd start

To check if the service is running run # /etc/init.d/vsftpd status you should get an output like this:
vsftpd (pid xxxx) is running…

Make sure you have the client installed in the machines you’ll issue the ftp command. To get it installed login as root and do the following

# yum install ftp

It will download the latest ftp version and install it (if you don’t have it yet).

While connecting from the client, if you get an error like “500 OOPS: cannot change directory:/home…” right after providing the user and password, check if the ftp home directory is allowed to be used in the ftp server

getsebool -a | grep ftp

allow_ftpd_anon_write --> on
allow_ftpd_full_access --> off
allow_ftpd_use_cifs --> off
allow_ftpd_use_nfs --> off
ftp_home_dir --> off
httpd_enable_ftp_server --> off

If your ftp_home_dir is set to off run the following

setsebool -P ftp_home_dir on

That’s it, now you should be able to connect  from a remote computer via FTP. Don’t forget to set up iptables properly to allow remote connections on port 20.





How to FTP and Command List

25 07 2009

Lots of people come to ask me how to send and receive files through FTP using the command window. Even this is a simple task I´ll show the way to do that and some examples.

Open your prompt and type

ftp ip_address (or the dns_address)

If it´s a secure ftp connection, you´ll be prompted to insert the username and the password.

When you  are logged in you should see the FTP prompt like this “ftp>“.

Now follows a list of commands to use within FTP:

1. Opening and closing connection

- ftp - starts an FTP session
- open hostname - connects to the specified host
- close - closes only the connection
-
quit - terminates the FTP session

2. Browsing on a remote machine

- dir - gives a full directory listing on the remote machine
- dir test* - displays only files and directories whose name begins with “test…”
- ls - same as dir, but provides a simplified listing of filenames

3. Directories in FTP

- pwd - prints the name of the current remote directory
- cd remote-directory – changes working directory on remote host
- lcd directory – changes the default directory on local host

4. Types of files

- binary - type this command at the FTP prompt to set binary mode before transferring binary files

- For example, use binary mode with the following types of files:

- SPSS System files
- SAS Transport files
- Stata Datasets
- Graphics files (e.g., *.gif, *.jpg, *.bmp, etc.)
- Microsoft Office documents (*.doc, *.xls, etc.)

- ascii - type this command at the FTP prompt to set ASCII mode before transferring text files.

- Use the ASCII mode with any of the following:

- Raw Data (e.g. *.dat or *.txt, codebooks, or other plain text documents)
- SPSS Portable files
- HTML files

5. Transferring files

- get test - copies file “test” from remote to local host (from current remote directory to current local directory)
- mget test.* data.dbf - copies files beginning with “test” and the file named data.dbf from remote to local host
- put test - copies file “test” from local to remote host.You musth have write access to the remove host for this to work.
- mput test.* data.dbf - copies files beginning with “test” and the file named data.dbf from local to remote host
- quit - closes connection and terminates FTP session

- If a file name contains spaces (e.g. on your Windows system) you should type the file name in quotation marks ” “,
but it is strongly recommended to rename such files before FTPing them.





Starting SSH Service on Linux/Unix

22 07 2009

Here we are once again, I´d like to share with you a quite easy thing but lots of people come to ask me about how to start a ssh service on linux so here we go!

 - Login as root and run the following:

    # service sshd status

- If it appears stopped then issue

    # service sshd start

- Then check the status again

   # service sshd status

You should get something like this

    openssh-daemon (pid  xxxx) is running…

Of course you have to make sure port 22 is open and accessible, for this check the OS firewall and if your computer is in a network under a router, setup the port fowarding in your router to point port 22 to you machine.

Setup SSH service to start when computer starts

    When we have the service up and running we don´t want to spend time starting the service everytime the machine starts (or restarts) so we set up the service to start always the machine starts.

- Run chkconfig as follows to check how the service is set up

    # chkconfig – -list sshd

You should get this output:

    sshd            0:off   1:off   2:off   3:off    4:off   5:off    6:off

As you can see the start levels 3, 4 and 5 are off so we have to turn it on running

    chkconfig – -level 345 sshd on

and now get this

    sshd            0:off   1:off   2:off   3:on    4:on    5:on    6:off

Finally done! Now you just have to access through port 22 from any other machine and you shoulb be able to reach you computer.





SCP/SSH without Password

6 07 2009

Hey all,

Last week I had to setup an access via scp without the password, I looked for it on the web and since it was hard to find something about this issue, I’m publishing a step by step on how to setup a SCP/SSH connection without providing the remote server password.

1 – First of all, perform a test to check if you can reach the server you want to access without a password via scp or ssh. Use the command below:

ssh user@servername or ssh user@ipaddress

The remote server password will be requested, if your connection is established you can move on to the next step.

2 – Checking if there’s a public key already generated

To check if your server (the one that will be accessed) already have a public key, issue the following command:

ls -l ~/.ssh

You should be able to see something like the files below. If the file id_dsa.pub was listed then you have the public key move to step 4.

-rwx–xr-x 1 user user  601 Feb  2 01:58 authorized_keys
-rwx–xr-x 1 user user  668 Jan  1 19:26 id_dsa
-rwx–xr-x 1 user user  599 Jan  1 19:26 id_dsa.pub
-rwx–xr-x 1 user user 6257 Feb  2 21:04 known_hosts

3 – Generating the public key

If  you performed the step 2 and don’t have the public key follow the steps below to get it done.

In the local server (the one that will be accessed) issue the command:

ssh-keygen -t dsa
Generating public/private dsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_dsa):     Press ‘enter’ here
Enter passphrase (empty for no passphrase):     Press ‘enter’ here
Enter same passphrase again:     Press ‘enter’ here
Your identification has been saved in /home/user/.ssh/id_dsa.
Your public key has been saved in /home/user/.ssh/id_dsa.pub.
The key fingerprint is:
2a:fs:6d:of:7s:7e:ko:2q:5f:75:x3:21:87:e4:f4:65 user@host

4 – Sending the id_dsa.pub file to the remote server (the one you want to run the ssh/scp)

Now simply move the file id_dsa.pub via scp to the remote server in the /home/remoteuser/.ssh folder as follows:

scp /home/homeuser/.ssh/id_dsa.pub remoteuser@ipaddress:/home/remoteuser/.ssh

5 – Generating the authorized_keys file in the remote server

The last step before get it ready for use is to generate the authorized_keys files, which will actually allows the local server connect without the password on the specific remote machine.

Using the id_dsa.pub file (in the remote server) perform the command as follows:

cat id_dsa.pub >> authorized_keys

If you have any doubts, fell free to post a comment.








Follow

Get every new post delivered to your Inbox.