{"id":727,"date":"2020-10-15T08:53:43","date_gmt":"2020-10-15T05:53:43","guid":{"rendered":"https:\/\/www.scalahosting.com\/kb\/?p=727"},"modified":"2024-07-09T16:15:14","modified_gmt":"2024-07-09T13:15:14","slug":"how-to-connect-to-my-vps-via-sftp","status":"publish","type":"post","link":"https:\/\/www.scalahosting.com\/kb\/how-to-connect-to-my-vps-via-sftp\/","title":{"rendered":"How to connect to my VPS via SFTP?"},"content":{"rendered":"\n<p><b>HTTP and HTTPS are the communication protocols<\/b><span style=\"font-weight: 400;\"> we use for viewing a website in our browsers, but before we can do that, the website&#8217;s operator needs to upload some files to a server connected to the internet. For many years, the easiest and most convenient way to do this was through <\/span><b>FTP (File Transfer Protocol)<\/b><span style=\"font-weight: 400;\">. It&#8217;s still in use today, and considering the fact that the technology is close to 50 years old, this is quite an achievement, but<\/span><b> FTP is starting to show its age<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n\n<p><b>Table of Contents:<\/b><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><b>What is SFTP?<\/b><\/li>\n\n\n\n<li><b>Why should I use it?<\/b><\/li>\n\n\n\n<li><b>What can I do with it?<\/b><\/li>\n\n\n\n<li><b>The pros and cons of SFTP<\/b><\/li>\n\n\n\n<li><b>How to make it more secure?<\/b><\/li>\n\n\n\n<li><b>How to set up an SFTP connection with a VPS from ScalaHosting?<\/b><\/li>\n\n\n\n<li><b>Conclusion<\/b><\/li>\n<\/ul>\n\n\n\n<p><span style=\"font-weight: 400;\">The truth is, the experts who developed the <\/span><b>File Transfer Protocol <\/b><span style=\"font-weight: 400;\">had nowhere near as many things to worry about as today&#8217;s website owners, and the problems were inevitable. Fortunately, there are enough people ready to ensure that there are solutions to <\/span><b>these problems<\/b><span style=\"font-weight: 400;\">. These same people created<\/span><b> SFTP (or SSH File Transfer Protocol)<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>What is SFTP?<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Before we can answer this question, we need to go back to the beginning of SSH \u2013 the underlying <\/span><b>communication technology that makes SFTP a great tool<\/b><span style=\"font-weight: 400;\"> for a number of different tasks. SSH stands for <\/span><b>Secure Shell<\/b><span style=\"font-weight: 400;\">, and it&#8217;s a remote administration protocol originally developed by a Finnish <\/span><b>researcher called Tatu Ylonen<\/b><span style=\"font-weight: 400;\"> as a way of mitigating the risk of password sniffing attacks. SSH&#8217;s first version was released in the 1990s, and alongside it, Ylonen also invested some work into a very early version of SFTP.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">In the early 2000s, the<\/span><b> Internet Engineering Task Force<\/b><span style=\"font-weight: 400;\"> (IETF) started working on<\/span><b> SSH-2 \u2013 a revised version of the protocol<\/b><span style=\"font-weight: 400;\"> that eventually came out in 2006 and brandished much better security and quite a few new features. SSH-2 was not compatible with <\/span><b>Tatu Ylonen&#8217;s version<\/b><span style=\"font-weight: 400;\">, which meant that when IETF took over, it also needed to overhaul the <\/span><b>original incarnation of SFTP<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">This proved to be a bit more complicated. At one point, there was a debate around whether or not <\/span><b>SFTP is a protocol or an entire remote file system<\/b><span style=\"font-weight: 400;\">, and this delayed the development a bit. Eventually, however,<\/span><b> in 2013<\/b><span style=\"font-weight: 400;\">, work on it was restarted, and the protocol has been in use ever since.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">You might be wondering what the difference between SSH and SFTP is. SSH is a protocol that lets administrators manage and execute remote commands on the server. <\/span><b>SFTP is an extension<\/b><span style=\"font-weight: 400;\"> that allows them to upload, download, and manage files via the secure connection provided by SSH.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>Why should I use it?<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">SFTP is sometimes referred to as<\/span><b> &#8220;Secure File Transfer Protocol,&#8221; <\/b><span style=\"font-weight: 400;\">and you probably won&#8217;t be too surprised to learn that security is the main reason why you should use SFTP over the standard FTP. Here are the differences in more detail.<\/span><\/p>\n\n\n\n<p><b>When connecting through a regular FTP connection<\/b><span style=\"font-weight: 400;\">, the client must be authenticated by the server, and, as you have probably guessed by now, this happens through a username and a password. These login credentials, as well as the rest of the information that is sent to the server, are transferred in plain text, which shouldn&#8217;t really be a<\/span><b> surprise given the protocol&#8217;s age<\/b><span style=\"font-weight: 400;\">.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">After all, <\/span><b>back in the 1970s,<\/b><span style=\"font-weight: 400;\"> the world wasn&#8217;t rife with hackers who could sniff through your communication, steal your passwords, or <\/span><b>hijack your connection<\/b><span style=\"font-weight: 400;\">. Nowadays, however, things are a little bit different, which is why you need to make sure that your connection to the remote host is secure.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">Because it&#8217;s based on SSH, SFTP<\/span><b> uses cryptography to secure the data in transit and ensure that only authorized users are able to manage files on the server.<\/b><span style=\"font-weight: 400;\"> First, the client and the host use a symmetric encryption algorithm to encrypt the connection. <\/span><b>Symmetric encryption<\/b><span style=\"font-weight: 400;\"> means that the data is encrypted and decrypted by one and the same key.&nbsp;<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">The key is created at the very beginning of the session using a key exchange algorithm, and the great thing about it is that<\/span><b> the client and the server don&#8217;t transmit it or share it with any other parties.<\/b><span style=\"font-weight: 400;\"> Instead, the key is calculated based on pieces of public data that are shared between the client and the server.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">When the connection is secured, the <\/span><b>SSH protocol<\/b><span style=\"font-weight: 400;\"> commands<\/span><b> the use of an asymmetric cryptographic algorithm to authenticate the client.<\/b><span style=\"font-weight: 400;\"> Asymmetric cryptography is based on public-private key pairs. In this scenario, the <\/span><b>public key encrypts the data<\/b><span style=\"font-weight: 400;\">, and the private one decrypts it. The server generates and encrypts a challenge and sends it to the client. If the client can decrypt it, it will prove that it has the private key and is authorized to communicate with the server.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">From a user&#8217;s perspective, <\/span><b>this whole mechanism is often hidden behind a simple username-and-password authentication mechanism. <\/b><span style=\"font-weight: 400;\">In other words, the steps you need to take in order to establish an SFTP connection are no more complicated than the ones you take during regular FTP sessions.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>What can I do with it?<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">Plenty of people think that <\/span><b>SFTP is the regular FTP <\/b><span style=\"font-weight: 400;\">run over a secure shell connection. This is not the case. The two protocols do share some functionalities like the ability to upload and download files and the <\/span><b>remote management of directories<\/b><span style=\"font-weight: 400;\">, but <\/span><b>SFTP gives clients a few additional capabilities.<\/b><span style=\"font-weight: 400;\"> These capabilities include remote file removal, directory listings, and the ability to deliver more detailed metadata with the files.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>The pros and cons of SFTP<\/b><\/h2>\n\n\n\n<p><b>SFTP is not the only means of securely transferring files between two connected computers<\/b><span style=\"font-weight: 400;\">. The <\/span><b>Secure Copy Protocol (SCP)<\/b><span style=\"font-weight: 400;\">, for example, also uses SSH to facilitate the copying of data between a client and a server, and the correct implementation of the rsync utility lets you achieve the same results. The limited functionality and the lack of support for some platforms, however, means that for most, these alternatives are not really viable. Usually,<\/span><b> users have only two options to choose from \u2013 SFTP or FTPS.<\/b><\/p>\n\n\n\n<p><b>FTPS is the implementation of the regular file transfer protocol over TLS<\/b><span style=\"font-weight: 400;\"> (<\/span><i><span style=\"font-weight: 400;\">Transport Layer Security<\/span><\/i><span style=\"font-weight: 400;\">). It, too, uses cryptography to ensure that the connection between a client and a server is secure, and it&#8217;s definitely preferable to using the plain old FTP.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">When compared to SFTP, however, it lags behind. Historically,<\/span><b> configuring FTPS to work with firewalls has been a challenge<\/b><span style=\"font-weight: 400;\">, and in addition to all the extra functionalities, SFTP also has a few useful features like the ability to continue interrupted transfers. In the past, SFTP was mostly supported by <\/span><b>command-line clients<\/b><span style=\"font-weight: 400;\">, which was a problem for less experienced users, but nowadays, applications with intuitive graphic interfaces like <\/span><b>FileZilla can also establish SFTP connections.<\/b><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">SFTP&#8217;s only real disadvantage is that it&#8217;s <\/span><b>more difficult to implement on the server side<\/b><span style=\"font-weight: 400;\"> and is therefore not provided by all hosting providers.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>How to make it more secure?<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">As you can see, <\/span><b>your SFTP connection is backed by an extremely complex cryptographic mechanism<\/b><span style=\"font-weight: 400;\">, which is there to ensure that your data is secure. For the sake of usability, however, in most cases, you log in with your username and password, and this is where things could go very wrong.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">A weak password can render all other security mechanisms completely useless in <\/span><b>many scenarios,<\/b><span style=\"font-weight: 400;\"> and SFTP communication, despite the complex cryptography it&#8217;s based on, is no exception. The stakes are pretty high as well.<\/span><\/p>\n\n\n\n<p><b>The same credentials that log you in through SFTP <\/b><span style=\"font-weight: 400;\">also give you SSH access, which means that if hackers get their hands on them, they can remotely execute commands on the server. You must make sure that all users who have<\/span><b> SSH and SFTP access use strong, unique passwords<\/b><span style=\"font-weight: 400;\"> as well as up-to-date clients with all the security updates applied. Of course, there are server-side measures that need to be in place as well, but they&#8217;re the responsibility of the web host.<\/span><\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><b>How to set up an SFTP connection with a VPS from ScalaHosting?<\/b><\/h2>\n\n\n\n<p><span style=\"font-weight: 400;\">SSH and SFTP access is available on our <\/span><a href=\"https:\/\/www.scalahosting.com\/managed-cloud-hosting.html\"><b>cloud VPS hosting solutions<\/b><\/a><span style=\"font-weight: 400;\">, but because of the risks associated with everyone <\/span><b>establishing SSH connections<\/b><span style=\"font-weight: 400;\"> to the server, by default, it is disabled. You can easily enable it through <\/span><a href=\"https:\/\/www.scalahosting.com\/spanel.html\"><b>SPanel<\/b><\/a><span style=\"font-weight: 400;\">, our all-in-one hosting management platform.<\/span><\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" width=\"1903\" height=\"1003\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/ssh-access-2.png\" alt=\"How to connect to my VPS via SFTP?, How to set up an SFTP connection with a VPS from ScalaHosting?\" class=\"wp-image-729\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/ssh-access-2.png 1903w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/ssh-access-2-300x158.png 300w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/ssh-access-2-1024x540.png 1024w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/ssh-access-2-768x405.png 768w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/ssh-access-2-1536x810.png 1536w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n\n\n\n<p><span style=\"font-weight: 400;\">To do that, you need to go to <\/span><b>Manage SSH Access <\/b><span style=\"font-weight: 400;\">under the <\/span><b>Accounts Management <\/b><span style=\"font-weight: 400;\">panel. You&#8217;ll see the list of all accounts you&#8217;ve created, and alongside them, there are toggle switches through which you can manage their SSH access. Above the list, there&#8217;s a help box reminding you that SSH connections to ScalaHosting&#8217;s servers pass through <\/span><b>port 6543 instead of the default port 22<\/b><span style=\"font-weight: 400;\"> and that users need to use their usernames and passwords in order to gain access.<\/span><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">If you&#8217;re initiating an SFTP session through a command-line interface, you need to use the following command:<\/span><\/p>\n\n\n\n<p><i><span style=\"font-weight: 400;\">sftp -p 6543 [username[@[the server&#8217;s hostname or IP]<\/span><\/i><\/p>\n\n\n\n<p><span style=\"font-weight: 400;\">You will be asked for your password, and after you&#8217;re successfully authenticated, you can use some of the following commands to perform various actions:<\/span><\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><td>\n<p><b>Command<\/b><\/p>\n<\/td><td>\n<p><b>Function<\/b><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">ls <\/span><\/i><span style=\"font-weight: 400;\">or <\/span><i><span style=\"font-weight: 400;\">dir<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">List the contents of the current directory on the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">cd<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Change the current directory on the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">pwd<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Show the present working directory on the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">put<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Upload a file to the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">get<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Download a file from the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">chmod<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Change the permissions on a file<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">rename<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Rename a file on the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">mkdir<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Create a directory on the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">rm<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Delete a file from the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">rmdir<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Delete an empty directory from the server<\/span><\/p>\n<\/td><\/tr><tr><td>\n<p><i><span style=\"font-weight: 400;\">exit<\/span><\/i><\/p>\n<\/td><td>\n<p><span style=\"font-weight: 400;\">Quit the session<\/span><\/p>\n<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>If you feel more comfortable logging into to your server through a Graphical User Interface (GUI), you can use an FTP client like FileZilla to establish your SFTP connection. The steps aren&#8217;t that different from the ones you take to set up a regular FTP session.<\/p>\n\n\n\n<p>The only thing you need to do is enter <strong><em>sftp:\/\/ <\/em><\/strong>before the server&#8217;s IP in the host field and specify the SSH port (in the case of ScalaHosting&#8217;s managed VPSs, it&#8217;s <strong>6543<\/strong>).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"759\" height=\"152\" src=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/204.png\" alt=\"How to connect to my VPS via SFTP?, How to set up an SFTP connection with a VPS from ScalaHosting? 2\" class=\"wp-image-3428\" srcset=\"https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/204.png 759w, https:\/\/www.scalahosting.com\/kb\/wp-content\/uploads\/2020\/10\/204-300x60.png 300w\" sizes=\"(max-width: 361px) 660px, (max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 910px, 1140px\" \/><\/figure>\n<\/div>\n\n\n<h2 class=\"wp-block-heading\"><b>Conclusion<\/b><\/h2>\n\n\n\n<p><b>FTP has played a major role in the development of the internet<\/b><span style=\"font-weight: 400;\">, and it&#8217;s safe to say that without it, the online world would be a very different place.<\/span><b> It wasn&#8217;t build with security in mind<\/b><span style=\"font-weight: 400;\">, however, and it can now put your entire online project at risk. Given the fact that you have alternatives like <\/span><b>SFTP that are built on complex cryptographic algorithms<\/b><span style=\"font-weight: 400;\">, you have no excuse for <\/span><b>using FTP.<\/b><\/p>\n","protected":false},"excerpt":{"rendered":"<p>HTTP and HTTPS are the communication protocols we use for viewing a website in our browsers, but before we can do that, the website&#8217;s operator needs to upload some files to a server connected to the internet. For many years, the easiest and most convenient way to do this was through FTP (File Transfer Protocol). [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[27],"tags":[],"class_list":["post-727","post","type-post","status-publish","format-standard","hentry","category-vps-hosting"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/727","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/comments?post=727"}],"version-history":[{"count":8,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/727\/revisions"}],"predecessor-version":[{"id":5763,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/posts\/727\/revisions\/5763"}],"wp:attachment":[{"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/media?parent=727"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/categories?post=727"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.scalahosting.com\/kb\/wp-json\/wp\/v2\/tags?post=727"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}