When getting more experience in web development. It's a good idea to know how to connect via Secure Shell (SSH). If you have upgraded to a VPS server or a dedicated server you will have access to this.
When searching for SSH connecting you will hear people talking about "Putty". Putty software allows you to remote login to computers systems.
When you SSH into a web server you are using a cryptographic network protocol. This allows you to make a secure connection over an unsecured network. there are some configurations and other techniques that can help accomplish certain tasks.
Connecting With Secure Shell
You really won't need a lot of information about SSH to be a great web developer. It is a good idea to know the basic navigation and file management. When connecting to your server, you will need to know the IP address, username, and password.
Putty Connect
- Type IP Address in Host Name and click Open.
- Enter username.
- Enter password.
Once connected it will be nothing but a black background and white text. Something like your Linux command line, or DOS in Windows. There is no use for your mouse, everything is done by commands on the keyboard.
SSH Basic Commands
When you first connect via SSH, be careful. Any changes to config files or settings can change how your server is running.
When you want to run a command you must hit "Enter". Your first Putty command, type:
This will show you server hardware information and what processes are currently running. This can be handy if you are experiencing lagging or slow response times. You can see what process are taking RAM or CPU.
It is a good idea to know what should be running even if nothing is wrong. This way you can easily identify if there is a problem.
Create A Directory and File
My commands are just examples. You may have to be altered to match your server's hierarchy.
You can easily create and edit directories and files. Navigate to your root web directory on your server by using the change directory command.
Let's make a new directory called "scripts". Type the following command:
Now that you have a "scripts" directory it time to make an index file. To make a new file let's us the vi editor. Type the following command:
You will now have a new window with nothing but black. This is the server's text editor, like notepad on a computer. Hit the "i" key on your keyboard. This will trigger a "-- INSERT --" at the bottom of the screen.
We are now ready to type in the editor. Type the following PHP script:
echo "New SSH Page";
?>
Once we are done typing we have to let the editor know. Hit the "ESC" key on the keyboard. Now save the file by using:
This write the changes to the file, and now to exit the editor type:
Congratulations you have created your first file by using SSH. If you navigate to your root website with your internet browser. You should see it display "New SSH Page".
Manage MySQL Database
Another good technique to learn is how to manage your MySQL databases. There will be a time when your MySQL tables may go down, get corrupted, and needs to be repaired.
You can repair MySQL tables with phpMyAdmin. But there have been better success rates when repairing them through SSH.
The reason is when repairing it through a client side GUI. Visitors can still try to access your table while you are trying to repair it. In an SSH environment, you can deny visitors while you repair.
MySQL Commands
To login into your MySQL database use the following commands:
You need to put the -u space username space -p then password. If entered correctly it will bring into the MySQL status. Now choose your database using:
This should get you in where you can use your standard MySQL queries. Like show tables, select, insert, and repair.
Remember to end everything with a ";".
Putty Command Cheat Sheet
Here are some of the most common commands you can use in your SSH environment.
Show server status
create directory
Move To Another Directory
Move up a directory level
Show the current path
List all files in a directory
List all files with a specific extension
Copy a file
Move a file
Create a file
Edit file with VI editor
Search for a file
Delete a file
Delete directory
Change permissions
exit SSH client
Putty Basics
These are some of the basic commands you can do in an SSH manager. Using putty is one of the most common ways. Putty is an open source application and you can download for free.
Just be careful if you don't know what you are doing. Start with the basic commands. Once you are comfortable in the environment start learning more advanced techniques.
What Do You Think?