<\/span><\/h2>\r\n\r\n\r\n\r\nYou can connect to a remote server via SFTP using the following command<\/p>\r\n\r\n\r\n\r\n
sftp\u00a0 user@IP_Address\r\n\r\nuser@IP_Address' password:\r\nConnected to IP_Address.<\/pre>\r\n\r\n\r\n\r\nYou can also use a hostname instead of the IP address.<\/p>\r\n\r\n\r\n\r\n
We already mentioned that SFTP is using the same protocol as SSH, so if SSH is not listening on the default port 22, you can specify the port in the command<\/p>\r\n\r\n\r\n\r\n
sftp -oPort=2345 user@IP_Address<\/pre>\r\n\r\n\r\n\r\nWhere ‘2345’ is the port number you are using.<\/p>\r\n\r\n\r\n\r\n
<\/span>2. List SFTP files in the current directory<\/strong><\/span><\/h2>\r\n\r\n\r\n\r\nThe SFTP command to list all files is ls , so that you can list all files and directories in the current working directory, as shown below.<\/p>\r\n\r\n\r\n\r\n
<\/p>\r\n\r\n\r\n\r\n
sftp> ls\r\ndirectory directory1\u00a0 file\u00a0 file.txt file.zip<\/pre>\r\n\r\n\r\n\r\nYou can also list the files on the local system<\/p>\r\n\r\n\r\n\r\n
sftp> lls<\/pre>\r\n\r\n\r\n\r\n<\/span>3. Navigate through directories<\/strong><\/span><\/h2>\r\n\r\n\r\n\r\nTo find the current working directory on the local server use<\/p>\r\n\r\n\r\n\r\n
sftp> pwd\r\nRemote working directory: \/home\/user<\/pre>\r\n\r\n\r\n\r\nfor the local server, use the following command<\/p>\r\n\r\n\r\n\r\n
sftp> lpwd\r\nLocal working directory: \/<\/pre>\r\n\r\n\r\n\r\nYou can easily change the working directory in SFTP. For the remote server use<\/p>\r\n\r\n\r\n\r\n
sftp? cd directory<\/pre>\r\n\r\n\r\n\r\nand for the local server use<\/p>\r\n\r\n\r\n\r\n
sftp> lcd directory<\/pre>\r\n\r\n\r\n\r\n<\/span>4. Upload files and directories using the put command<\/strong><\/span><\/h2>\r\n\r\n\r\n\r\nYou can upload single or multiple files or directories from the local machine to the remote one.<\/p>\r\n\r\n\r\n\r\n
sftp> put filename<\/pre>\r\n\r\n\r\n\r\nTo upload multiple files use the following command<\/p>\r\n\r\n\r\n\r\n
sftp> mput file1 file2 file3<\/pre>\r\n\r\n\r\n\r\nTo upload a directory to the remote server, you have to create the destination directory on the remote server first, and then start the upload<\/p>\r\n\r\n\r\n\r\n
sftp> mkdir directory\r\nsftp> put -r directory\/<\/pre>\r\n\r\n\r\n\r\n<\/span>5. Download files and directories using the get command<\/strong><\/span><\/h2>\r\n\r\n\r\n\r\nDownload a single file from the remote to the local machine<\/p>\r\n\r\n\r\n\r\n
sftp> get file<\/pre>\r\n\r\n\r\n\r\nor download multiple files with the ‘mget’ command<\/p>\r\n\r\n\r\n\r\n
sftp> mget file1 file2 file3<\/pre>\r\n\r\n\r\n\r\nDownload a directory and all its content with the following command<\/p>\r\n\r\n\r\n\r\n
sftp> get -r directory<\/pre>\r\n\r\n\r\n\r\n<\/span>6. Create and remove directories<\/strong><\/span><\/h2>\r\n\r\n\r\n\r\nCreate a new directory on the remote server<\/p>\r\n\r\n\r\n\r\n
sftp> mkdir newdirectory<\/pre>\r\n\r\n\r\n\r\nCreate a new directory on the local server<\/p>\r\n\r\n\r\n\r\n
sftp> lmkdir newdirectory<\/pre>\r\n\r\n\r\n\r\n<\/span>7. Getting Help<\/strong><\/span><\/h2>\r\n\r\n\r\n\r\nYou can find all SFTP commands with a short description by executing ‘help’ or ‘?’.<\/p>\r\n\r\n\r\n\r\n
sftp> ?\r\n\r\nAvailable commands:\r\nbye\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Quit sftp\r\ncd path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Change remote directory to 'path'\r\nchgrp grp path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Change group of file 'path' to 'grp'\r\nchmod mode path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Change permissions of file 'path' to 'mode'\r\nchown own path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Change owner of file 'path' to 'own'\r\ndf [-hi] [path]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display statistics for current directory or\r\nfilesystem containing 'path'\r\nexit\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Quit sftp\r\nget [-Ppr] remote [local]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Download file\r\nreget remote [local]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Resume download file\r\nhelp\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display this help text\r\nlcd path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Change local directory to 'path'\r\nlls [ls-options [path]]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display local directory listing\r\nlmkdir path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Create local directory\r\nln [-s] oldpath newpath\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Link remote file (-s for symlink)\r\nlpwd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Print local working directory\r\nls [-1afhlnrSt] [path]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display remote directory listing\r\nlumask umask\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Set local umask to 'umask'\r\nmkdir path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Create remote directory\r\nprogress\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Toggle display of progress meter\r\nput [-Ppr] local [remote]\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Upload file\r\npwd\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Display remote working directory\r\nquit\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Quit sftp\r\nrename oldpath newpath\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Rename remote file\r\nrm path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Delete remote file\r\nrmdir path\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Remove remote directory\r\nsymlink oldpath newpath\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Symlink remote file\r\nversion\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Show SFTP version\r\n!command\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Execute 'command' in local shell\r\n!\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Escape to local shell\r\n?\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Synonym for help<\/pre>\r\n\r\n\r\n
\r\n\r\n\r\n