In this article, we'll show you how you can automate your publishing process with secure copy (SCP). In the <a href="/support/website/jekyll/how-to-customize-your-jekyll-site/">customizing Jekyll</a> article we learned about how you can change the base directory of your site. This means you will be building your site into a specific directory, which is going to be important later. </p> <p> Then, we can create a simple script that will grab your base directory and copy it to your server with minimal effort on your part. </p> <h2>SSH Access</h2> <p> In order for this process to work easily and quickly, you will want to set up an <a href="/support/server/ssh/how-to-generate-ssh-keys/">SSH key</a> on your computer and then <a href="/support/website/general-server-setup/self-managed/manage-ssh-keys#add-key">add the key to your server</a>. Why? SCP uses the <a href="/support/server/ssh/how-to-login-ssh/">SSH</a> protocol to transfer files to your server. This means you will require a password in order to make our script run. With an SSH key, however, we can skip the password phase and transfer files directly. This is also considered a more secure way to control access to your server. </p> <h2>Change your Jekyll Build Base Directory</h2> <p> As mentioned above, you will want to <a href="/support/website/jekyll/how-to-customize-your-jekyll-site/">customize your Jekyll installation</a> to "build" your site into a directory called <em>public_html</em>. This will work better with your InMotion Hosting cPanel server, which has already chosen the <em>public_html</em> directory as the <a href="/support/website/where-to-upload-files/">document root</a>. </p> <h2> Creating the SCP Script </h2> <p> Now that you have added the SSH key to your server, we can create the SCP script. This kind of scripting is very specific and may differ based on individual use cases. This is why I'll emphasize that this is merely one way among many to accomplish the same goal. You might take this as inspiration to create your own script, or, what we've provided here may be sufficient for your needs. </p> <p> What we're going to do is create an executable script that will transfer our <code>public_html</code> directory in our Jekyll site to our server location. </p> <p> The steps must be completed on your local computer, not your server. </p> <ol class="article_list"> <li>Create a new file on your computer called <em>publish-site.sh</em> (you may name it anything you want, this is only an example)</li> <li>Open the file for editing with your text editor</li> <li>Add the following code into your file:<br/><pre class="code_block"> #!/bin/bash scp -rp /path/to/jekyll/public_html [email protected]:~/</pre><br/>Making sure that you update the path to your Jekyll site and substitute the example.com server information for your own</li> <li>Open your terminal application</li> <li>Use the <span class="cli">cd</span> command to change into the directory where you created the <em>publish_site.sh</em> file (if you created it in your home folder, you may already be in the right place)</li> <li>Use the following command to make the file executable:<br/><pre class="cli"> sudo chmod +x <span style="color:green;">publish-site.sh</span> </pre></li> <li>Run the executable file by adding a period and forward slash before it:<br/><pre class="cli"> ./<span style="color:green;">publish-site.sh</span> </pre></li> </ol> <p> Now your command should automatically use SCP to transfer the files to your server without your having to log into your server. Every time you make changes to your site, use <code>jekyll build</code> to build the site and your custom script to transfer the files.