Diary

August 24, 2009

mono issue: Standard output has not been redirected or process has not been started.

Filed under: Uncategorized — Himanshu @ 6:04 am

Fix is found from http://www.debianadmin.com/running-aspnet-applications-in-debian-and-ubuntu-using-xsp-and-mono.html

   1:  
   2:  sudo find /usr/bin | grep gmcs
   3:  
   4:  if result is NOT
   5:  /usr/bin/gmcs
   6:  /usr/bin/gmcs2
   7:  
   8:  try
   9:  1)install mono-gmcs package (if only have “/usr/bin/gmcs”)
  10:  or
  11:  2)in case you have only “/usr/bin/gmcs2? make symlink on it named gmcs
  12:  sudo ln -s /usr/bin/gmcs2 /usr/bin/gmcs

restart apache2 or xsp or your web server and check result in browser.

August 21, 2009

Creating My SQL database and user

Filed under: my-sql — Himanshu @ 7:40 am

I sent email from my hotmail a/c  to my user at server where I had hosted postfix, let’s see if it goes through. See my prior post for the context.

Anyway, this post is for Installed My SQL and PHP. Its pretty easy to install mysql and php in ubuntu. Use apt-get install and you are done. I haven rarely used MySQL, and never used it from command line. After installing mysql also tried creating database as: mysqladmin create <databasename>. Command complainted about password for user. I used switch to supply password and command prompt was on next line. I assumed the command must be successful.

Now, I wanted to setup wordpress. And want to use different database, user then I had created and used in prior command. I wanted to have wp user to do anything on its database, but not more then that.

Googled a bit and found that user can be created in mysql with host specification, found it interesting. (see this). So concept is user can be created with host specification or with wild card (which is % not *). and user will have access to the database accordingly. So same user accessing database from localhost will have more permissions then if s/he access database from outside server.

So, I used following commands to create database and user. This commands needs to be run from mysql command prompt which can be started using mysql –user=root –password=<root-user-password>. I had used root, so you are seeing root user in the command, but any other user who has permission of creating database, creating user and allocating permissions.

   1: CREATE USER '<user-name>'@'localhost' IDENTIFIED BY '<password-for-the-user>';
   2: CREATE USER '<user-name>'@'%' IDENTIFIED BY 'password-for-the-user';
   3: GRANT ALL PRIVILEGES ON <database-name>.* TO '<user-name>'@'localhost';
   4: GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP ON <database-name>.* TO '<user-name>'@'localhost';

Opps, forgot to mention. Please make sure you first create database and then run line 3 and line 4.

August 20, 2009

Setting up email server - 1

Filed under: linux, mail server, ubuntu — Himanshu @ 6:42 am

I was going through ubuntu server edition, where I found that ubuntu comes with a utility called tasksel. That was not installed on my server, so went ahead and did apt-get install for it, and that resolved the issue of not having it.

I did select mail server from it’s checkbox, and it installed successfully after some queries. Well, I’m saying successfully because it didn’t gave me any error. I could see some more process running while I do ps -ef after installation has completed.

But then what next, I was pathless again. I did some more googling over it, and I found http://jonsview.com/2009/03/26/how-to-setup-email-services-on-ubuntu-using-postfix-tlssasl-and-dovecot. I completed what he said but ehlo localhost was not having two lines that he said but below

   1: ehlo localhost
   2: 250-server Hello localhost.localdomain [127.0.0.1], pleased to meet you
   3: 250-ENHANCEDSTATUSCODES
   4: 250-PIPELINING
   5: 250-EXPN
   6: 250-VERB
   7: 250-8BITMIME
   8: 250-SIZE
   9: 250-DSN
  10: 250-ETRN
  11: 250-AUTH DIGEST-MD5 CRAM-MD5
  12: 250-DELIVERBY
  13: 250 HELP

Now, what? Pathless again.

I learn mail command and tried it. It was giving warning as postdrop: warning: unable to look up public/pickup: No such file or directory quick googling lead me to http://ubuntuforums.org/showthread.php?t=666018 which told me that I need to fire command

   1: sudo mkfifo /var/spool/postfix/public/pickup
   2: sudo /etc/init.d/postfix restart

after which warnings disappeared, but mail didn’t reached to hotmail account.

Update-1:

Wow, I killed sendmail process, restarted postfix and I could see the entries that above URL was saying. And also received the emails in hotmail account, in junk as I was expecting it to be.

I was also seeing some process that was indicating my hotmail account in its description. I didn’t understand it so I restarted the server, but will try sending some more emails and update.

August 19, 2009

Setup SSH to authenticate only by key

Filed under: Uncategorized — Himanshu @ 6:23 am

Assumption:

  • Client is windows and you will connect to server using putty
  • Server is Ubuntu, I have tried this with Ubuntu 9.04 and it worked
  • Root login is possible to server and have access to command line

 

Step 1: Prepare server for ssh server

   1: apt-get install ssh
   2: sudo apt-get install openssh-server

First line will install ssh on the server and second line with install openssh-server. If you are doing apt-get for the first time, make sure you have done apt-get update once so that server is updated for repositories.

Step 2: Create public - private keys

   1: ssh-keygen

This will create public - private key on the server, keys can also be created using PUTTYGEN.EXE but in this post, we will do it on server. Once public - private keys are generated. they will be placed in ~/.ssh folder. Private key will be in id_rsa and public key will be id_rsa.pub. One server we need only public key.

Step 3: Download private key using PSFTP

Login to server using psftp, see help of putty (putty.chm) in case if you need help in using psftp. You will need to use open, lpwd, lcd, cd and get command of psftp

Step 4: Generate private key (of .ppk format) using PUTTYGEN.EXE

Open downloaded private key from server into puttygen.exe. You may need to type in passphrase if you have setup one while using ssh-keygen. Once key is open click on save private key button in puttygen.exe. This will generate .ppk file which can be later used with putty.exe

Step 5: Copy public key content to authorization key file on server

On server go to ~/.ssh using console where public and private key was generated, and execute following commands

   1: cat id_rsa.pub >> ~/.ssh/authorized_keys
   2: rm id_rsa.pub
   3: rm id_rsa

This will create authorizaed_keys which server will use while authenticating user. And also delete public - private key file generated by ssh-keygen

Step 6: Make sure server accepts login using RSA keys

open /etc/ssh/sshd_config this is configuration file of ssh server. Make sure file has following configured

   1: RSAAuthentication yes
   2: PubkeyAuthentication yes 

Use /etc/init.d/ssh reload to reload the changed configuration

Step 7: Try out login using RSA key file

Open putty.exe from client and type in host (name or ip) and supply .ppk file. On logon to server, it should ask user name, will also ask for passphrase if setup while generating key files.

ssh

Step 8: Disable plain text password authentication

open /etc/ssh/sshd_config file again and make sure you have following configuration entries to disable plain text password authentication

   1: ChallengeResponseAuthentication no
   2: PasswordAuthentication no

Use /etc/init.d/ssh reload to reload the changed configuration. Also try out that its disabled using putty and supply user name without RSA key file

Step 9: Optionally change the port number for extra security

open /etc/ssh/sshd_config file and change configuration for port.

Powered by WordPress