I want to present a quick jumpstart to connecting with and using FTP and SSH, which are both very useful tools. Let’s jump right in and start with FTP.
Getting Started with FTP
FTP is slow if you’re dealing with lots of files, but it gets the job done and is very reliable. I typically use Dreamweaver for my FTP since I code while I’m doing it, but Filezilla is a much better FTP client and is a great piece of freeware. I will include screenshots from there as a guide.
The Requirements
To establish a connection, you will need the following:
1. A username.
2. A password.
3. An address. Sometimes an IP Address, sometimes a domain / subdomain.
4. An FTP client such as Filezilla.
Once you have those from your host, web person, or client, you can connect. This tutorial does a good job of covering the basics of moving files. I recommend, if using Filezilla (or any client), that you use synchronized browsing by navigating to the corresponding folders on your local machine and server, and then clicking the chain icon in the toolbar. This ensures you are always working with the correct files in the correct location.
FTP Tips
- If you get a generic error that you can’t connect or the connection times out, you probably have the address wrong. Try using the IP address from the website’s A record (which you can look up here), or simple ftp.example.com is sometimes how it’s set up.
- If your error says incorrect username or password, that is probably accurate.
- Sometimes the username ends with @example.com. For example, if you thought your username was testuser, it may actually be testuser@example.com.
- Port 21 is for regular FTP, port 22 is for SFTP, which should work the same but is encrypted and on secure servers, often the only way to do it.
- FTP almost never times out when uploading large files, even if they are many gb. Use it in favor of an online file manager.
- FTP is actually very slow for uploading large directories. If you have a way of unzipping files either via an online file manager or via SSH, you should zip all your local files up and upload them that way. It will be many times faster.
Getting Started with SSH
SSH is very powerful and very useful in many circumstances. You can easily unzip files, search for files with a given name or search the content of files for strings or anything else. What you can’t really do is upload files. Let’s get started!
First, you need Putty. It’s the best SSH client. For SSH, much like FTP, you’ll need a hostname / IP address, username, and password. Usually you will enter the username and password in once you’ve already connected, so you don’t need to enter those in right away (though you can in more advanced settings). This tutorial will get you started right away if you don’t know how to initiate the actual connection.
If you don’t know what your username, password, and hostname are, Google how to use SSH with your particular host, or just contact the host. Many hosts, such as Godaddy, don’t have SSH activated by default, and are strange in where the username and password come from.
Controls and commands once you are connected
To paste – Right Click
This is useful for copying passwords and scripts you have prepared.
To enter a command – Type it and then press enter
Commands
pwd – Print Working Directory
This will print the full path to the current directory you are in.
ls – List all files and folders
This will list every file and folder in your current folder.
cd examplefolder – Change Directory
This changes your current directory to one specified. For example, if you’re in your website root, you might type “cd wp-content” and it will bring you to the wp-content directory.
unzip filename.zip – Unzip a file
Obviously, this is how you unzip a file. By default I believe it doesn’t overwrite existing files and folders, but you will be prompted if it is trying and have the option of saying yes or no. Note that if you are just listing the filename by itself, you will need to be in the same folder as that file.
ncdu – List combined size of folder contents
This one is awesome! If you want to know where all of the size of your site is stemming from, you can find it in no time with this command. It will show you how big all of the folders and files are in your root, and then you can navigate down to find out exactly where all the big files are. Huge time saver! Type “q” to exit this command.
grep -rli “searchstring” * – Search the content of files for a string
This is a neat trick to find a specific string within file contents across the entire server. And it runs relatively quickly because it’s server-side. More details here.
Those are really all the commands I find myself needing! I have used it in more advanced ways, but for the most part that’s all I need. Take a look at my post about removing malicious code for how to use SSH to remove malicious scripts.
SSH Tips & Tricks
- The first time you connect, Putty will typically warn you that you don’t know who you are connected to. If you are sure your IP address is correct, you can usually just say to go forward anyway, as this is what always happens. If you want to be really secure, you can use RSA keys but they are a pain to work with.
- SSH can scan files very quickly, because the server runs these commands locally and returns the results to you when it’s done. Filezilla can search for filenames, but it takes a very long time.
- Unzipping files and deleting files is also very fast and very easy with SSH.
- There is basically no limit to what you can do with SSH, just Google it.
There you have it! FTP and SSH are both very powerful and useful in the right situations. Learn to use them, and Google anything you don’t know.
4 Comments on “SSH / FTP Connection Basics + Tips & Tricks”
I usually use Dreamweaver as well, but had to do something for a different client and used PuTTy just recently. Now I am getting FTP errors when I try to use Dreamweaver on my other site. Could using Putty have reset something that I now need to change back? The command I used in PuTTy was c:\putty -ssh site.com -l username -pw pwd. Do I need to undo that -ssh part of the command? Is it related at all? TIA
I can’t imagine they are at all related, no. Unless you did another action, simply connecting via SSH should not have affected Dreamweaver or any other FTP connection method.
How can I play videos directly when I open in ftp server with VLC… I have tried everything but without success. Please guide me properly. I am using ftp in windows 10, not any 3rd party software.
I guess I’ve never heard of that, before. I have no idea if that’s possible!