Upload a File From My Computer With Putty
How to upload and download files through SSH using PuTTY (for Windows users)
In this tutorial we'll testify yous how to transfer files from your local computer to your hosting account and vice versa through SSH (Secure Vanquish) using PuTTY. PuTTY is an application with which Windows users tin can connect to their hosting accounts through SSH and execute commands, transfer files, etc. To learn more about PuTTY, where to detect information technology, how to configure it and what you lot accept to do to connect to your account through SSH, read the tutorial on connecting to your account through SSH (for Windows users).
In this tutorial we assume that you already have installed the whole PuTTY installation package on your local computer and yous know how to configure it to connect to your account.
As yous have probably noticed the PuTTY installation parcel contains several other applications, besides PuTTY itself. These include Pageant, PSCP, PSFTP, etc. What you demand for file transferring is either PSCP or PSFTP:
SCP (Secure Re-create) and SFTP (SSH File Transfer Protocol) are network protocols which use SSH for file transfer. When information technology comes to transferring speed, they are a fleck slower than the more than commonly used FTP only they are much more secure.
PSCP and PSFTP are the PuTTY applications for transferring files over SCP and SFTP. SFTP is a newer protocol designed to work with SSH-two (Secure Beat out version 2). Despite its name, PSCP also uses SFTP as its first choice for transferring files when the server to which PSCP is continued is an SSH-ii server. Practically all servers, including HostKnox servers, are SSH-2 servers.
The main difference between PSCP and PSFTP is that PSCP is primarily used for downloading and uploading files (information technology can also be used to list files in a remote directory). PSFTP is more like an FTP client (e.g. FileZilla), meaning that it can exist used not only to transfer files, but also to browse the files and folders on your account, to delete them, etc. PSFTP and PSCP are, nevertheless, command line applications. This ways that they are used through the Command Prompt of your Windows operational organisation and you have to type the commands manually.
And then, to starting time PSCP or PSFTP you have to beginning the Command Prompt offset. To do this, click on the Windows Beginning button in the lower left corner of your screen, then click on Run... and in the window that opens type cmd and click on OK. This will launch the Control Prompt from which you can start PSCP or PSFTP.
In order to connect to your account and transfer files you also have to get-go Pageant and add your private SSH fundamental. For more than information on this cheque the tutorial on connecting to your account through SSH using PuTTY.
First nosotros'll go over PSCP and nosotros'll prove you how to start information technology and use it to transfer files from your local computer to your hosting account and vice versa. To start it, you lot take to type a command in the Command Prompt to add PSCP to the system path. If, for example, you have installed all the PuTTY applications in a folder called putty on your local D drive, the control should wait like this: set path=%path%;d:\putty. Afterward yous blazon it press Enter on your keyboard to execute the command.
After you practise that you're set to type commands to transfer files with PSCP. To upload a file from your local computer to the public_html directory on your account (the directory where you have to put the files you lot need for your site), you have to execute a command in the Control Prompt that looks like this:
pscp d:\documents\case.txt username@e.hostknox.com:/home/username/public_html
This command volition transfer a text file called instance.txt from the documents folder on your local D drive to the public_html directory on your account. You have to supersede username in both places with your actual master username and, if needed, the server name. The part between the @ symbol and the colon is the accost of the server and the part afterwards the colon is the path to the public_html folder (/home/username/public_html).
To download a file from your account to your local computer just type showtime the path to the file on your hosting account and then the identify on your local estimator where you desire to download it:
pscp username@e.hostknox.com:/home/username/public_html/example.txt d:\documents
The just spaces in the pscp command are later on pscp and between the two paths. If you want to upload a file which has spaces in its file name (or the directory containing it has spaces), you have to put the whole path to the file on your local calculator in quotation marks. The same has to be done if you download a file on your local computer in a directory that has spaces in its proper noun. For example, you want to upload a file called my example file.txt from a folder chosen documents on your local D bulldoze to the public_html directory on your account:
pscp "d:\documents\my instance file.txt" username@eastward.hostknox.com:/home/username/public_html
If you want to download the same file (a file with spaces in the name) from your hosting business relationship, you lot merely need to put quotation marks around the file name:
pscp username@east.hostknox.com:/home/username/public_html/"my example file.txt" d:
The above command will download a file called my example file.txt from your account to the D drive on your local computer.
Notice also that when yous specify the path to your account you have to use forward slashes (/) while for the path on your local computer you have to utilise backward slashes (\).
The above commands volition only work for unmarried files. Y'all can transfer multiple files by using wildcards (*). For case, the following command will download all the files (without any subdirectories) inside the documents folder from you account to the D drive on your reckoner:
pscp username@e.hostknox.com:/home/username/public_html/documents/* d:
If you want to transfer a directory together with all the files and subfolders in it, you accept to add the option -r. For instance:
pscp -r d:\documents username@e.hostknox.com:/home/username/public_html
The to a higher place command volition upload the unabridged documents folder with everything within it from your local computer to the public_html directory on your account.
A tip that may salve you lot some fourth dimension: past pressing the upward pointer key on your keyboard you lot can browse through the previous commands that you have executed. With the left and right pointer keys yous can move the line cursor to right mistakes in your commands.
At present, let's motion to PSFTP. To beginning PSFTP, open the Command Prompt and use the same command as with PSCP to add PSFTP to the system path (e.1000. set path=%path%;d:\putty). Don't forget that you also need to start Pageant and add your private SSH key. After you execute the set up path command, y'all just need to type psftp followed past a infinite and your master username and the name of the server: eastward.g. psftp username@e.hostknox.com.
This will log you in your business relationship in the directory /home/username. Besides transferring files, you can apply Unix/Linux commands to browse and manage the files and folders on your business relationship. For example, once you're logged in if you type just ls and press Enter you'll see a list of the directories inside /home/username. One of them is the public_html directory. You can open that folder and arrive your electric current working directory by typing cd public_html. With cd .. you'll open the parent directory of your current directory. Here is a list with some useful commands:
ls - shows the content of the current directory
cd directoryname - changes the electric current working directory to the ane specified (the specified directory has to be a subdirectory of the current 1, otherwise yous take to type the full path)
cd .. - become ane directory upward
mkdir newfolder - creates a new directory chosen newfolder inside the electric current directory
rm filename - deletes a file with the specified proper name (e.g. filename); the file has to be in the current directory or you have to type the total path
rmdir directoryname - deletes a directory, information technology has to be empty
lcd directoryname - changes the current working directory on your local computer to the one specified; for case, lcd d:\documents will modify the working directory on your local figurer to the documents binder on the D bulldoze
lpwd - displays the proper name of the electric current working directory on your local figurer
Now, let's go back to the chief purpose of PSFTP: transferring files. Files can be downloaded with the get command:
get /home/username/public_html/examplefile.txt d:\documents\examplefile.txt
You have to supersede username with your actual master username.
The above command will download a file called examplefile.txt from the public_html directory on your account to a folder called documents on your local D drive. Detect that here with the command in the in a higher place course we have also specified the name of the target file that nosotros're going to salve on the local reckoner (d:\documents\examplefile.txt). This has to be done when you're downloading a file to a directory on your local computer that is not your current working directory. Unlike PSCP, where if you don't specify a proper name the file will be saved with the original name, with PSFTP if you don't specify a name for the file the get command might not work. You lot have the choice whether to apply the same proper noun for the target file or to use a unlike ane, but in both cases the content of the file will be the aforementioned as that of the source file.
Since with PSFTP you tin browse and change the working directory on your account (cd control), you don't take to type the full path to the file on your business relationship that yous want to download. Using the in a higher place instance, if you utilize the cd control (east.chiliad. cd public_html) to make public_html the electric current working directory on your account, the control would expect like this:
get examplefile.txt d:\documents\examplefile.txt
The same is true for the current working directory on your local computer. If y'all change it with the lcd command to d:\documetns (lcd d:\documents) the higher up command would look like this:
become examplefile.txt examplefile.txt
Assuming the working directory on your account is public_html and the working directory on your local computer is d:\documents, the above control will download a file chosen examplefile.txt from the public_html directory on your account to the documents folder on your local D drive. In this case you don't even take to blazon the name of the target file when you download it to the current working directory on your computer. You tin just use get examplefile.txt and the file will be downloaded in your working local directory with the same proper name every bit the source file.
To download a directory with all its content (including subdirectories), you have to add, as with PSCP, the selection -r:
get -r newfolder d:\newfolder
The to a higher place control volition download a directory called newfolder from the electric current directory on your account to the D bulldoze on your local computer. If you don't specify a name for the directory on you local drive (east.thou. get -r newfolder d:) PSFTP will download only the contents of newfolder to your local D drive without the binder itself. And then the contents of newfolder will be scattered on your D drive. This, equally with files, is the example when the current working directory on your local computer is non your local D bulldoze. If the working directory on your local computer is the D bulldoze, you can just use get -r newfolder. This will download non simply the contents but as well the binder itself to the working directory on your computer (D bulldoze in this example). Again, as with files, if yous want to you can specify a different name for the target directory (e.g. get -r newfolder newfolder1).
With the command mget you can download multiple files at the same fourth dimension. For example, mget examplefile1.txt examplefile2.txt will download the 2 files from the current working directory on your account to the current working directory on your local reckoner. With the -r option yous can apply mget to download multiple directories (eastward.g. mget -r dir1 dir2).
The PSFTP command for uploading files is put. Basically the same rules apply to this command as the ones for become. Merely in this case start y'all specify the file and path on your local computer and and then on your business relationship:
put d:\documents\examplefile.txt /home/username/public_html/examplefile.txt
The above command volition upload a file called examplefile.txt from the documents binder on your local D bulldoze to the public_html directory on your business relationship. Similarly to the get command, if you lot are uploading a file to a directory that'due south not your electric current working directory you lot take to specify not but the path on your business relationship simply also the proper name with which the file will be saved.
If yous're uploading the aforementioned file equally in the in a higher place example simply yous have changed the current working directory on your local computer to d:\documents and the working directory on your business relationship to public_html, you only demand the command:
put examplefile.txt
With the put command you can also employ the -r option to upload a directory together with its subdirectories and files (e.g. put -r exampledir). Yous tin use mput to upload multiple files at one time (e.g. mput examplefile.txt examplefile1.txt) or mput -r to upload multiple directories (e.chiliad. mput -r exampledir exampledir1).
Some other thing useful to know is that with both commands (put and go) if the file name or directory name has spaces in it, you take to put quotation marks around the proper noun (e.g. put "my instance file.txt").
marlowsaidecalown.blogspot.com
Source: https://www.hostknox.com/tutorials/ssh/putty/file-transfer
Post a Comment for "Upload a File From My Computer With Putty"