Wednesday, February 23, 2011

DS - Putty

Putty File Transfer Commands in SSH Protocol

Using SSH (secure shell) protocol during file transfer can decrease the chances that your web server's security will be compromised. There are a variety of SSH clients available. Putty, an open source SSH client, offers a number of advantages. This article will explain how to use it.
One of the most important aspects of transferring files (uploading or downloading) to a web server is security. The basic method of transferring is FTP, which is not secure; it sends transmitted information in clear text form. This increases the risk of eavesdropping, and in the long run can increase the chances of having your web server access compromised.

However, the solution to this problem is to use SSH (another name: “secure shell”) protocol during file transfer. SSH effectively encrypts the communication channel between the client (your computer) and the SSH server. In this way, any hacker or eavesdropper has no means of identifying your passwords, login information, etc as your packets travel on the Internet. This drastically improves the security of your file transferring session.

Putty SSH client is an open source SSH client for Windows-based operating systems (Windows 7, XP, etc). Other aspects include how to establish SSH sessions and use it to browse web server files. Simple SSH commands will be discussed; there will also be a detailed discussion of transferring and moving files from the client computer to an SSH server.

how to execute command line statements in Putty, Let’s get started.

Enable SSH in your web hosting account
If you have a paid hosting account, find out from your web hosting support whether they have SSH included as one of their hosting features. If your web hosting package includes SSH, you need to enable it before you can use it to connect and transfer files. Consult your web hosting support for details.

If your web hosting package does not include SSH, you may try to switch to other hosting companies, but this is rare -- almost all Linux/Unix/Apache-based hosting includes SSH functionality in a paid hosting account. In my experience, depending on your web hosting company, adding SSH features or enabling them can cause your site to experience some down time, so you had better prepare for it. You can always consult your web hosting company for any additional SSH support.

To test if you have SSH enabled in the server:

Step 1: Go to Start -> All programs -> Accessories -> Command Prompt
Step 2: On the Windows DOS prompt, ping your website by executing your command (replace the domain with yours): ping php-developer.org
The command above will ping the website http://www.php-developer.org/ . Your objective is to learn the IP address of the website server, for example: 82.197.130.134
Step 3: Once you know your website server's IP address, execute the following command, and then press enter: ssh YOURFTPUSERNAME@YOURIPADDRESS
If the reply is something like this:
ssh: connect to host 82.197.130.134 port 22: connection refused
You have NOT yet enabled your SSH access. Replace the above examples with your own FTP username and website IP address. See sample screen shot below:
***********************

***********************
The PuTTY Event Log

If you choose "Event Log" from the system menu, a small window will pop up in which PuTTY logs significant events during the connection. Most of the events in the log will probably take place during session startup, but a few can occur at any point in the session, and one or two occur right at the end.

You can use the mouse to select one or more lines of the Event Log, and hit the Copy button to copy them to the clipboard. If you are reporting a bug, it's often useful to paste the contents of the Event Log into your bug report.

Starting new sessions
PuTTY's system menu provides some shortcut ways to start new sessions:
Selecting "New Session" will start a completely new instance of PuTTY, and bring up the configuration box as normal.
Selecting "Duplicate Session" will start a session with precisely the same options as your current one - connecting to the same host using the same protocol, with all the same terminal settings and everything.
The "Saved Sessions" submenu gives you quick access to any sets of stored session details you have previously saved. See section 4.1.2 for details of how to create saved sessions.

Changing your session settings
If you select "Change Settings" from the system menu, PuTTY will display a cut-down version of its initial configuration box. This allows you to adjust most properties of your current session. You can change the terminal size, the font, the actions of various keypresses, the colours, and so on.
Some of the options that are available in the main configuration box are not shown in the cut-down Change Settings box. These are usually options which don't make sense to change in the middle of a session (for example, you can't switch from SSH to Telnet in mid-session).

Copy All to ClipboardThis system menu option provides a convenient way to copy the whole contents of the terminal screen and scrollback to the clipboard in one go.

Clearing and resetting the terminalThe "Clear Scrollback" option on the system menu tells PuTTY to discard all the lines of text that have been kept after they scrolled off the top of the screen. This might be useful, for example, if you displayed sensitive information and wanted to make sure nobody could look over your shoulder and see it. (Note that this only prevents a casual user from using the scrollbar to view the information; the text is not guaranteed not to still be in PuTTY's memory.)
The "Reset Terminal" option causes a full reset of the terminal emulation. A VT-series terminal is a complex piece of software and can easily get into a state where all the text printed becomes unreadable. (This can happen, for example, if you accidentally output a binary file to your terminal.) If this happens, selecting Reset Terminal should sort it out.

************************
Putty only displays command prompt of a remote Linux computer in Windows.
The commands that you type in are simply Linux commands. They are not putty commands. Here are few examples:
ls - to list files in a directory:
Code:
ls
handbook-draft.pdf  iso
ls -lh
total 3.4M
-rw-r--r-- 1 pavlo pavlo 3.4M 2007-05-15 05:53 handbook-draft.pdf
drwxr-xr-x 2 pavlo pavlo 4.0K 2007-04-10 00:25 iso
ls iso/
rhel-5-client-x86_64-disc6.iso
cd - change directory (navigate to some directory):
Code:
cd iso
cp - copy a file:
Code:
cp ../handbook-draft.pdf .
mv - move a file (also used to rename files):
Code:
mv handbook-draft.pdf howto.pdf
rm - remove a file:
Code:
rm handbook-draft.pdf
mkdir - make directory:
Code:
mkdir new
pwd - show your current location:
Code:
pwd
/home/pavlo/example/iso
whoami - find out which user you are:
Code:
whoami
pavlo
date - display date and time
Code:
date
Tue May 15 06:07:45 UTC 2007
some commands are distribution specific, such as apt in Debian. Example:
Code:
apt-get install expect
which downloads and installs "expect" package.
man - most important of all commands (opens manual pages for other commands):
Code:
man expect
q - quit or exit an application (for example when done reading man page, type q to exit).
Here I found a list of some Linux commands: Linux bash commands - MAN Pages

No comments:

Post a Comment