Hello! I’m Shunsuke.
I’m a web engineer at a global company.
This site provides information for beginners who are studying programming to become web engineers.
This time, I received this question.
Teach me how to use the sftp command!
It’s a command I don’t use that often, so I look it up every time too. lol
In this article, I’ll explain this question!
What is the sftp command?
The sftp command is used to exchange files with the server.
Used to place files on the server and retrieve files from the server.
If you use it frequently, it’s easier to use a client like Cyberduck.
How to use the sftp command!
If you haven’t registered your host, try setting it up this way!
Connect to the server
Connect to the server using the sftp command.
XXXXX should be the host name of the server registered in config.
$ sftp XXXXX
Retrieve a file
Retrieve a file from the server.
As with ssh, you can use cd and ls, so use those to find the file location!
sftp> get xxxx.txt
Place the file on the server.
You can specify the file path as a full path or as a path relative to the connected directory.
sftp> put xxxx.txt
Exit the sftp command
Disconnects communication with the server.
Surprisingly, few people know the disconnect command.
This is a summary of the basic usage of the sftp command.
For simple file transfers, I like to use the command.
Basically, it’s just get and put, so it’s easy to remember compared to other commands!
From now on, I won’t have to look them up to use them!
I use this command when I want to retrieve files from the server, but I don’t need to use the client for this purpose.
When you get used to it, it’s faster to use the sftp command than to configure the client.
It’s safer to use the client, though.