- How to Use the Mac Terminal as an FTP or SFTP Client
- Logging into the Server
- Using FTP
- Using SFTP
- 1. Uploading and Downloading Files
- Using FTP or SFTP
- 2. Creating a New Folder
- Using FTP or SFTP
- 3. Renaming Files on the Server
- Using FTP or SFTP
- 4. Deleting Files
- Using FTP
- Using SFTP
- 5. Moving Files within the Remote Server
- Using FTP or SFTP
- 6. Check “Last Modified” Date
- Using FTP or SFTP
- 7. Check and Modify Permissions
- Using FTP or SFTP
- 8. Create New Files
- Using FTP or SFTP
- 9. Edit Existing Files
- Using FTP or SFTP
- 10. Creating Duplicate Copies of Files
- Using FTP or SFTP
- Harness the Power of the Mac Terminal with FTP or SFTP
- Запуск FTP SFTP сервера на macOS
- Запуск FTP сервера в macOS
- Запуск SFTP сервера в macOS
- Отключение сервера
- FTP на Mac: как зайти через Finder или другие бесплатные ФТП-клиенты
- Как подключиться к FTP-серверу на Mac с помощью Finder
- Как подключиться к FTP-серверу на Mac с помощью Cyberduck
- Другие бесплатные FTP-клиенты для Mac
How to Use the Mac Terminal as an FTP or SFTP Client
File Transfer Protocol (FTP), and Secure File Transfer Protocol (SFTP) are two of the most widely used protocols for transferring files between a local device and a remote server. They are frequently used by web developers to push changes to their servers, and as such, there are a lot of FTP clients that are available. However, there is also a rather powerful tool built into a Mac that can allow users to use FTP, and SFTP protocols to interface with remote servers.
In this article I will be detailing how you can use the Terminal (Mac) as an FTP or SFTP client, to do a variety of tasks on remote servers. For the purpose of illustration, I’m using a test server with Linux, Apache, MySQL and PHP installed on it, with SSH access enabled. I will be telling you how you can accomplish basic FTP/SFTP tasks such as uploading/downloading files, renaming, moving, deleting etc. using the macOS’ Terminal, instead of a third party FTP client.
Note : To use SFTP, you will need to have SSH access enabled on your server. If you don’t have SSH access, you can contact your hosting provider, or you can use FTP. But keep in mind that FTP is generally not considered secure, so be careful.
Logging into the Server
Logging into the remote server is pretty straightforward. You will need a FTP/SFTP username and password to log into the server. FTP might allow for anonymous log-ins, but it’s better to authenticate using a username and password.
Using FTP
The command to log-in into a remote server using FTP, is:
ftp server_ip
You will then be prompted for your username, type it in, and hit Enter. Next, the Terminal will ask you for your password, key it in, hit Enter, and you will be logged in.
Using SFTP
The command to log-in to a remote server using SFTP, is:
sftp username@server_ip
You will then be prompted for the password. Key it in, and hit Enter to log in.
1. Uploading and Downloading Files
One of the basic functions of an FTP/SFTP client is the ability to upload files from the local host to the remote server, and to download files off of the remote server.
Using FTP or SFTP
The command to upload files to a remote server, is:
put path_to_local_file remote_file
For example, if I wanted to upload a file called index.txt, the command will become:
put /Users/akshaygangwar/index.txt index.txt
This command will put the file called “index.html” from my home directory, into the working directory in the remote server.
Note : To find out your working directory, you can use the command “pwd”
- Download Files
The command to download files off of a remote server, is:
get path_to_remote_file local_file
For example, if I wanted to download a file called newfile.txt, the command will become:
get newfile.txt newfile.txt
This command will download the file called “newfile.txt” from the working directory on the remote server into the working directory on my Mac.
2. Creating a New Folder
Creating folders (directories) on a remote server is another important task that is accomplished by FTP clients.
Using FTP or SFTP
Creating a new folder using the Terminal is easy. It’s the same command in both FTP and SFTP protocols:
mkdir directory_name
For example, if I wanted to create a folder by the name of “Beebom”, the command will become:
This will create a folder named “Beebom”, in the working directory on the remote server.
3. Renaming Files on the Server
Renaming files on the remote server can be accomplished easily by using the Terminal as a client.
Using FTP or SFTP
The command to rename files on a remote server using the Terminal as an FTP/SFTP client can be done with the following command:
rename old_name new_name
For example, if I wanted to change the name of “newfile.txt” to “mainlog.txt”, the command will become:
rename newfile.txt mainlog.txt
This will rename the file “newfile.txt” to “mainlog.txt”
4. Deleting Files
The Terminal can also let you delete files off the remote server. The commands in this case are different for both FTP and SFTP, and I am stating both of them separately.
Using FTP
The command to delete files off a remote server using FTP, is:
delete file_name
For example, if I wanted to delete the file called “beebomold.txt”, the command will become:
This will delete the file “beebomold.txt” off of the remote server.
Using SFTP
The command to delete files off a remote server using SFTP, is:
rm file_name
For example, if I wanted to delete the file called “beebomold.txt” using SFTP, the command will be:
This will delete the file “beebomold.txt” from the remote server.
5. Moving Files within the Remote Server
Using the Terminal as an FTP client can also allow you to move files within the remote server itself, exactly the way you would do it in a third party FTP client.
Using FTP or SFTP
The command to move files within the server in both FTP and SFTP is:
rename file_name path_to_new_file/file_name
For example, if I wanted to move a file called “testresults.txt” from the “test” directory to the “results” directory, the command will become:
rename testresults.txt results/testresults.txt
This will move the file “testresults.txt” to the sub-folder “results”.
6. Check “Last Modified” Date
Checking the “Last Modified” date for a file or a folder is useful if you need to know what files and folders were updated when. You can achieve this on the Terminal as well.
Using FTP or SFTP
The command to check the last modified date for a file is:
ls -l file_name
This command displays some information in a tabular form. The column with the date and time values corresponds to the “Last Modified” value.
For example, if I wanted to check the date that “testresults.txt” was last modified, the command will be:
ls -l testresults.txt
7. Check and Modify Permissions
Having files set to the proper permissions is very important. Sometimes, wrong permissions can lead to your web app not even loading.
Using FTP or SFTP
- Checking Permissions
Checking and modifying permissions using the Terminal as a client is very straightforward, the command is:
ls -l file_name
This command displays some information in a tabular form. The first column displays the permissions on the file.
For example, if I wanted to check the permissions on the file “testresults.txt”, I will use the command as:
ls -l testresults.txt
- Modifying Permissions
If you see a file that has incorrect permissions, or if you just want to play around with the permissions, you can use the Terminal to modify the permissions of the file. The command is:
chmod permissions_value file_name
For example, if I wanted to give full read, write and execution permissions to the file “testresults.txt”, the command will become
chmod 777 testresults.txt
This command will give read, write and execute permissions to the file “testresults.txt”
8. Create New Files
Creating new files on the server is a task that is not easily done on the Terminal. However, that doesn’t mean it’s not possible. The issue with creating new files is that you have to have a copy of the file on your laptop before you can upload it to the server.
Using FTP or SFTP
The commands to create a file on the remote server, are:
!touch file_name
put file_name file_name
For example, if I want to create a file “newtest.txt” on the server, the commands will become:
put newtest.txt newtest.txt
This will create a new file called “newtest.txt” and upload it to the server.
9. Edit Existing Files
Editing existing files is also an important feature. You can edit a file in the Terminal itself, by using programs such as nano, emacs etc., which are already built-in to the Terminal. Nano is simpler to understand, and I will be using it in this example.
Using FTP or SFTP
The commands to edit existing files on the remote server, are:
get file_name file_name
!nano file_name
put file_name file_name
For example, if I want to edit the file “newtest.txt”, the commands will become:
get newtest.txt newtest.txt
put newtest.txt newtest.txt
These commands will edit the file “newtest.txt” and upload it back to the server.
10. Creating Duplicate Copies of Files
When you are editing files in the remote server, it is better to have a copy of the original file, just in case you mess something up.
Using FTP or SFTP
To create a duplicate copy of a file on the remote server, the commands are:
get file_name file_name
!mv file_name new_file_name
put new_file_name new_file_name
For example, if I want to create a duplicate copy “newtest_copy.txt” of “newtest.txt”, the commands will become:
get newtest.txt newtest.txt
!mv newtest.txt newtest_copy.txt
put newtest_copy.txt newtest_copy.txt
Harness the Power of the Mac Terminal with FTP or SFTP
Now that you know how you can use the Terminal as an FTP or SFTP client, you can use it for FTPing or SFTPing into your development server, without having to worry about third-party applications installing bloatware, or not securing your traffic. If you have any issues with using FTP or SFTP from your Terminal, or if you think we missed something out, let us know in the comments section below.
Источник
Запуск FTP SFTP сервера на macOS
Как запустить FTP и SFTP сервер под управлением MAC OS
Естественно возможно скачать отдельный сервер и многие так и поступают, но зачем, если в mac OS “из коробки” уже имеется встроенный ftp/sptp сервер, которого для большинства задач будет вполне достаточно. Просто, по умолчанию встроенный сервер отключен и нам остается просто его включить. Этим мы и займемся.
Запуск FTP сервера в macOS
Для начала запустите Терминал (/Applications/Utilities/Terminal.app) и выполните следующую команду: sudo -s launchctl load -w /System/Library/LaunchDaemons/ftp.plist
Проверьте работает ли сервер можно командой ftp localhost . Если в окне терминала Вы увидите что-то похожее:
Значит все получилось и сервер работает. Для подключения к серверу используйте свою учетную запись или создайте новую, специально для ftp подключений (что будет правильнее с точки зрения безопасности). Для доступа к файлам на сервере воспользуйтесь командой connect to server в Finder либо с помощью любого ftp-клиента.
Запуск SFTP сервера в macOS
Если по соображениям безопасности Вам все таки требуется шифрование передаваемых данных, тогда входим в Системные настройки -> Общий доступ и ставим галочку напротив Удаленный вход.
В блоке “Разрешить доступ” желательно выбрать пункт “Только этим пользователям” и указать своего пользователя.
Проверить работоспособность этого сервера также можно командой sftp localhost
Отключение сервера
Отключается встроенный SFTP сервер снятием галочки с пункта Удаленный вход в системных настройках.
Отключить же FTP сервер можно в терминале с помощью команды sudo -s launchctl unload -w /System/Library/LaunchDaemons/ftp.plist
ЗАМЕЧАНИЕ!
FTP и SFTP серверы могут конфликтовать между собой и не рекомендуется их держать включенными одновременно.
Источник
FTP на Mac: как зайти через Finder или другие бесплатные ФТП-клиенты
FTP является очень полезным протоколом, позволяющим передавать файлы через Интернет. При необходимости соединение с сервером на Mac можно осуществить как с помощью встроенных решений, так и сторонних программ (FileZilla, CyberDuck). Эти клиенты предлагают широкий спектр настроек, позволяющих полностью контролировать работу с FTP.
Но что делать, если сторонние программы не установлены, нет возможности сделать это или разбираться в них. В этом случае клиентом FTP может выступить привычный всем файловый менеджер Finder. Это приложение сможет соединиться с удаленным сервером, а его папки будут показаны по аналогии с локальными.
Как подключиться к FTP-серверу на Mac с помощью Finder
Получить доступ к удаленному FTP серверу с помощью нативного для macOS приложения Finder очень просто. Для этого проделайте следующее:
1. Запустите Finder.
2. В строке меню программы выберите Переход → Подключение к серверу.
3. Откроется новое окно, в котором надо будет ввести имя сервера или его IP адрес. Можно будет нажать кнопку «+», чтобы добавить этот ресурс в список Избранного и обеспечить быстрый к нему доступ впоследствии. Обратите внимание, что протокол может быть выбран как FTP, так и FTPS. Тут все зависит от уровня безопасности сервера. Важно не перепутать FTPS с SFTP. Это два разных способа подключения. Первый относится к безопасному соединению с использованием FTP, а второй работает на основе протокола SSH с добавленными к нему функциями FTP.
4. На этом шаге в строке с адресом вы можете задать и имя пользователя с его паролем, но если не сделать этого, то данные просто надо будет ввести позже.
5. Нажмите кнопку «Подключиться».
6. Нажмите еще раз кнопку «Подключиться».
7. В появившемся окне надо ввести имя пользователя и его пароль, если они не были заданы раньше. При необходимости можно выбрать вариант подключения к серверу в качестве гостя.
8. Стоит поставить галку рядом с опцией «Запомнить этот пароль в связке ключей», чтобы сохранить данные авторизации для последующих подключений.
9. Нажмите кнопку «Подключиться».
10. Появится окно с папками в том же стиле, как при работе с локальными папками Mac.
Примечание! При всем удобстве использования Finder в качестве FTP-клиента стоит отметить возможность доступа к серверу только в режиме «только для чтения». Другими словами файлы можно скачать с сервера на компьютер, но нельзя наоборот.
Как подключиться к FTP-серверу на Mac с помощью Cyberduck
Если вам все же нужно что-то разместить на сервере, то придется воспользоваться продуктами сторонних разработчиков, например, Cyberduck.
Приложение Cyberduck распространяется совершенно бесплатно, однако при желании можно внести пожертвования на сайте разработчиков.
Чтобы подключиться к FTP-серверу при помощи программы CyberDuck осуществите следующие шаги:
1. Запустите программу CyberDuck для Mac.
2. Нажмите на кнопку «Новое подключение».
3. В первой строке нового окна оставьте значение «FTP (Стандартное подключение)», если вам требуется стандартный доступ к серверу.
4. Ниже понадобится ввести адрес сервера, имя пользователя, пароль. Здесь тоже есть возможность анонимного входа и хранения данных авторизации в связке ключей.
5. Нажмите на кнопку «Подключиться».
Как видите, интерфейс программы очень прост и интуитивно понятен.
Другие бесплатные FTP-клиенты для Mac
FileZilla (скачать)
ClassicFTP (скачать)
Пожалуйста, оцените статью
Средняя оценка / 5. Количество оценок:
Оценок пока нет. Поставьте оценку первым.
Примечание! При всем удобстве использования Finder в качестве FTP-клиента стоит отметить возможность доступа к серверу только в режиме «только для чтения». Другими словами файлы можно скачать с сервера на компьютер, но нельзя наоборот.
Источник