January 9th, 2012
First things first you should do the following:
sudo apt-get install openssh-server ssh
This will install the server and the ssh daemon, you can start the server by doing:
service ssh start
You also have the following at your disposal(don’t forget to sudo if you aren’t running as root):
service ssh restart #restarts the server
service ssh reload #reloads the configuration file for the server
service ssh stop #stops the server
service ssh status #gives you a short description of the status of the server
Now that you have some knowledge of how to start, restart, and stop the server we are going to take a look at configuration.
sudo vim /etc/ssh/sshd_config #or nano if your lazy or whatever you normally use gedit is perfectly valid here
The first thing you’ll want to do is set it up to bind to an address (NOTE: The default is to listen on all address’s so if you have your computer in dmz(w/e its called) where your internet ip is assigned to your computer you may want to change this).
So navigate to where it says ListenAddress this tells the server what ip to listen on, your going to want to change this to 127.0.0.1 (which is the loopback address ie it means it will run locally).
The default for this server is to allow ssh scp and sftp connections, you are pretty much done if you don’t mind having those options available for me I wanted to have an sftp only server so I’ll show you guys how in case you wanted to know,
Go to the very last line of your sshd_config(again as earlier mentioned its in /etc/ssh/)
Add this to the bottom:
Match Group sftponly
sudo groupadd sftponly
Now we need to add a user to the sftponly group
sudo adduser sftpguy
sudo usermod -g sftponly sftpguy
Next we want to chown /home/ to root
sudo chown root:root /home/
sudo mkdir /home/sftpguy #if it doesn’t exist
sudo chown sftpguy:sftponly /home/sftpguy
You should be done with your sftp server now and can now do:
sudo service ssh start
Hope this helps someone who wants to know this information
August 21st, 2010
This tutorial was originally going to be a naked lunch style tutorial taken from a conversation in #ubuntu-us-tn the original conversation is located here. Due to the time that has gone by since the converstation and the scope of an introductory tutorial the cut and past with commentary style is unfeasible so this will be a traditional tutorial. Thanks to netritous for the ground work in IRC that night.
- ~$: bash prompt
- >> mysql prompt
SQL is probably the easiest languages to learn, and it’s 80-90% universal to all databases..depends on the DB (of course), learn it for MySQL db and you know it for MSSQL, SQLite, Derby, Cloudscape, etc.*
To start with MySQL it will be best to install MySQL from the Ubuntu repositories with:
~$: sudo apt-get install mysql-server
During the install process you will be prompted to enter a root password for MySQL you can leave this blank if you choose but remember that if a password is entered it will be necessary create Databases and tables.
Once MySQL is installed you will to login:
~$: mysql -u root (if you set a password include) -p
When you see the word ‘Schema’ that just another word for database.*
The only things you can do with data in a db is view/add/change/delete..that’s it, so if you keep that in mind it makes it a little easier. *
After having logged in to mysql with the above first thing will be to create the database as follows:
Next you will need to tell MySQL to use the database you created:
Now we will create a table called employees:
>> CREATE TABLE employees (id INT(20), firstname CHAR(20), lastname CHAR(20), position CHAR(20), PRIMARY KEY (id);
The PRIMARY KEY attribute makes the field id the unique index where every row in that field must be different to ease finding an item within that table (this comes in very usful in larger databases).
On a quick side note in creating the table each field was attributed with a datatype and a max character length (These can be changed later with ALTER_TABLE). The datatype INT is used for fields that are going to be comprised only of integers, CHAR only of alpha characters, there is also VARCHAR (alpha-numeric), DATE (dates), BLOB (images) and many others a list of MySQL datatypes can be found at http://dev.mysql.com/doc/refman/5.0/en/data-types.html.
Now to populate the table this can be down within mysql or from a source file. For this tutorial we will go from with in MySQL. First so we can see the structure of the table you will type:
that should display the following;
| Field | Type | Null | Key | Default | Extra |
| id | int(20) | NO | PRI | 0 | |
| firstname | char(20) | YES | | NULL | |
| lastname | char(20) | YES | | NULL | |
| position | char(20) | YES | | NULL | |
4 rows in set (0.02 sec)
Next we will add data to the table:
>> INSERT INTO employees VALUES ('0', 'John', 'Doe', 'System Admin');
To see the table:
>> SELECT * FROM employees
Since we have id set as the Primary Key any attempt to duplicate that value will result in the following error message:
"ERROR 1062 (23000): Duplicate entry '0' for key 'PRIMARY'"
As stated above that is why a primary key is crucial to prevent duplication and allow for finding a specific user despite the potential of the Same name.
That is the basics to getting started with MySQL, more to come later possibly including using GUI interfaces to manipulate a Schema.
* From netritious in the original IRC conversation