How to Upload a File With Putty
How to upload and download files through SSH using PuTTY (for Windows users)
In this tutorial we'll show yous how to transfer files from your local computer to your hosting account and vice versa through SSH (Secure Beat) using PuTTY. PuTTY is an application with which Windows users can connect to their hosting accounts through SSH and execute commands, transfer files, etc. To learn more about PuTTY, where to observe it, how to configure it and what you 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 presume that yous already accept installed the whole PuTTY installation bundle on your local computer and you lot know how to configure information technology to connect to your account.
As you take probably noticed the PuTTY installation package contains several other applications, too PuTTY itself. These include Pageant, PSCP, PSFTP, etc. What you need for file transferring is either PSCP or PSFTP:
SCP (Secure Copy) and SFTP (SSH File Transfer Protocol) are network protocols which employ SSH for file transfer. When information technology comes to transferring speed, they are a bit slower than the more usually used FTP but 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 piece of work with SSH-two (Secure Shell version 2). Despite its name, PSCP also uses SFTP as its first pick for transferring files when the server to which PSCP is connected is an SSH-2 server. Practically all servers, including HostKnox servers, are SSH-ii servers.
The main divergence between PSCP and PSFTP is that PSCP is primarily used for downloading and uploading files (it tin can also exist used to list files in a remote directory). PSFTP is more than like an FTP customer (due east.g. FileZilla), meaning that information technology can be used non only to transfer files, only as well to browse the files and folders on your account, to delete them, etc. PSFTP and PSCP are, however, command line applications. This means that they are used through the Control Prompt of your Windows operational system and you have to type the commands manually.
And so, to showtime PSCP or PSFTP you have to get-go the Command Prompt first. To do this, click on the Windows Start push in the lower left corner of your screen, and then click on Run... and in the window that opens type cmd and click on OK. This will launch the Command Prompt from which you can kickoff PSCP or PSFTP.
In lodge to connect to your account and transfer files you lot likewise have to start Pageant and add together your private SSH cardinal. For more information on this check the tutorial on connecting to your account through SSH using PuTTY.
Commencement we'll go over PSCP and nosotros'll prove you how to start it and apply information technology to transfer files from your local estimator to your hosting account and vice versa. To beginning information technology, you take to type a command in the Control Prompt to add PSCP to the system path. If, for example, you accept installed all the PuTTY applications in a folder called putty on your local D drive, the command should look like this: set path=%path%;d:\putty. Afterward you lot blazon information technology press Enter on your keyboard to execute the command.
After you practice that yous're set to blazon commands to transfer files with PSCP. To upload a file from your local figurer 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 Command Prompt that looks similar this:
pscp d:\documents\case.txt username@e.hostknox.com:/home/username/public_html
This command will transfer a text file chosen instance.txt from the documents binder on your local D drive to the public_html directory on your business relationship. You lot have to supercede username in both places with your bodily master username and, if needed, the server name. The part between the @ symbol and the colon is the address of the server and the role after 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 first the path to the file on your hosting business relationship then the place on your local computer where you lot want to download it:
pscp username@e.hostknox.com:/home/username/public_html/example.txt d:\documents
The but spaces in the pscp control are later pscp and between the two paths. If yous want to upload a file which has spaces in its file name (or the directory containing it has spaces), yous have to put the whole path to the file on your local computer in quotation marks. The aforementioned has to be done if you download a file on your local computer in a directory that has spaces in its proper name. For example, you desire to upload a file called my case file.txt from a folder called documents on your local D bulldoze to the public_html directory on your account:
pscp "d:\documents\my instance file.txt" username@e.hostknox.com:/home/username/public_html
If you lot want to download the same file (a file with spaces in the proper noun) from your hosting account, you only need to put quotation marks around the file proper name:
pscp username@e.hostknox.com:/home/username/public_html/"my example file.txt" d:
The above command volition download a file called my example file.txt from your account to the D drive on your local computer.
Notice besides that when yous specify the path to your account you lot have to use frontwards slashes (/) while for the path on your local computer you have to utilise astern slashes (\).
The above commands volition only work for single files. You tin can transfer multiple files past using wildcards (*). For example, the following command volition download all the files (without any subdirectories) inside the documents binder from you account to the D drive on your computer:
pscp username@eastward.hostknox.com:/domicile/username/public_html/documents/* d:
If you want to transfer a directory together with all the files and subfolders in information technology, you have to add the option -r. For case:
pscp -r d:\documents username@eastward.hostknox.com:/home/username/public_html
The above command will upload the entire documents folder with everything inside it from your local computer to the public_html directory on your business relationship.
A tip that may save yous some time: by pressing the up arrow primal on your keyboard yous tin can scan through the previous commands that you have executed. With the left and right pointer keys yous tin move the line cursor to correct mistakes in your commands.
At present, let'due south motion to PSFTP. To offset PSFTP, open the Control Prompt and use the same command every bit with PSCP to add PSFTP to the system path (east.thou. set path=%path%;d:\putty). Don't forget that y'all as well need to start Pageant and add your individual SSH central. After you execute the set path command, you but need to type psftp followed by a infinite and your master username and the name of the server: due east.g. psftp username@e.hostknox.com.
This will log y'all in your account in the directory /home/username. Besides transferring files, you can use Unix/Linux commands to browse and manage the files and folders on your account. For example, once you're logged in if you type simply ls and press Enter y'all'll come across a list of the directories inside /domicile/username. I of them is the public_html directory. Yous tin 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 listing with some useful commands:
ls - shows the content of the current directory
cd directoryname - changes the electric current working directory to the one specified (the specified directory has to be a subdirectory of the current one, otherwise yous have to type the full path)
cd .. - get one directory upwards
mkdir newfolder - creates a new directory called newfolder within the current directory
rm filename - deletes a file with the specified name (east.g. filename); the file has to exist in the electric current directory or you have to blazon the total path
rmdir directoryname - deletes a directory, information technology has to be empty
lcd directoryname - changes the current working directory on your local calculator to the ane specified; for example, lcd d:\documents will change the working directory on your local calculator to the documents binder on the D bulldoze
lpwd - displays the proper name of the electric current working directory on your local computer
Now, let's get back to the main purpose of PSFTP: transferring files. Files tin can exist downloaded with the become command:
become /home/username/public_html/examplefile.txt d:\documents\examplefile.txt
You lot have to supervene upon username with your actual master username.
The to a higher place command will download a file called examplefile.txt from the public_html directory on your account to a folder chosen documents on your local D drive. Notice that here with the command in the to a higher place form we have also specified the proper name of the target file that we're going to save on the local computer (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 electric current working directory. Unlike PSCP, where if you don't specify a name the file will be saved with the original proper name, with PSFTP if you don't specify a name for the file the get command might not work. You take the option whether to use the same name for the target file or to apply a different one, just in both cases the content of the file volition be the same as that of the source file.
Since with PSFTP you tin browse and change the working directory on your business relationship (cd control), y'all don't have to blazon the full path to the file on your account that you want to download. Using the in a higher place example, if you lot use the cd command (due east.thousand. cd public_html) to make public_html the current working directory on your business relationship, the control would await similar this:
become examplefile.txt d:\documents\examplefile.txt
The same is true for the current working directory on your local reckoner. If you alter it with the lcd command to d:\documetns (lcd d:\documents) the in a higher place command would await like this:
get examplefile.txt examplefile.txt
Bold the working directory on your business relationship is public_html and the working directory on your local reckoner is d:\documents, the above command will download a file called 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 have to type the name of the target file when y'all download it to the electric current working directory on your computer. Y'all tin can just utilize go examplefile.txt and the file will be downloaded in your working local directory with the same name as the source file.
To download a directory with all its content (including subdirectories), you accept to add, as with PSCP, the selection -r:
go -r newfolder d:\newfolder
The above command volition download a directory called newfolder from the current directory on your account to the D drive on your local estimator. If you don't specify a proper noun for the directory on you local bulldoze (e.g. get -r newfolder d:) PSFTP will download merely the contents of newfolder to your local D bulldoze without the folder itself. And then the contents of newfolder volition exist scattered on your D drive. This, as with files, is the instance when the electric current working directory on your local computer is not your local D drive. If the working directory on your local calculator is the D drive, you lot tin just utilise get -r newfolder. This will download not but the contents but too the folder itself to the working directory on your computer (D bulldoze in this example). Again, as with files, if you want to you can specify a different proper noun for the target directory (east.g. get -r newfolder newfolder1).
With the command mget you tin can download multiple files at the same time. For example, mget examplefile1.txt examplefile2.txt volition download the ii files from the current working directory on your account to the electric current working directory on your local figurer. With the -r option you can use mget to download multiple directories (due east.g. mget -r dir1 dir2).
The PSFTP command for uploading files is put. Basically the aforementioned rules apply to this control as the ones for go. Only in this case first you specify the file and path on your local computer then on your business relationship:
put d:\documents\examplefile.txt /home/username/public_html/examplefile.txt
The above command will upload a file called examplefile.txt from the documents folder on your local D drive to the public_html directory on your account. Similarly to the become command, if you are uploading a file to a directory that's non your current working directory you have to specify not only the path on your account just also the name with which the file volition be saved.
If you're uploading the aforementioned file equally in the above example just you have changed the electric current working directory on your local reckoner to d:\documents and the working directory on your account to public_html, you just need the command:
put examplefile.txt
With the put command yous can too employ the -r option to upload a directory together with its subdirectories and files (east.g. put -r exampledir). You lot tin use mput to upload multiple files at once (e.k. mput examplefile.txt examplefile1.txt) or mput -r to upload multiple directories (e.k. mput -r exampledir exampledir1).
Some other thing useful to know is that with both commands (put and get) if the file name or directory name has spaces in it, you have to put quotation marks around the name (e.g. put "my case file.txt").
Source: https://www.hostknox.com/tutorials/ssh/putty/file-transfer
0 Response to "How to Upload a File With Putty"
Enregistrer un commentaire