SSH to Web Host


Uncategorized

Updated Jul 11th, 2023

SSH to Hostinger

Move files securely without FTP on a Windows 10 machine.

Can use a third party deployment service to deploy from GitHub repo but these cost money, need configuration, etc. You also may not be deploying often enough to justify the cost and setup. Back in the day we would use ftp but this isn’t secure.

Video here

Original Post to SiteGround

I followed the steps on Siteground’s website and this video here.

Create key on Siteground and save to file in .ppk format via notepad. I needed to install PuTTy. run pscp from a command prompt?

Alternatively, you can always run pscp.exe by its full pathname, e.g.
“C:\Program Files\PuTTY\pscp.exe” The PuTTY home web site here.

Open the puTTygen to create the key int he ppk format. When you run Pageant, it will put an icon of a computer wearing a hat into the System tray. It will then sit and do nothing, until you load a private key into it. Run PuTTy and paste in the hostname and port (from Siteground). This opens a new puTTy terminal and you need to type or paste in the use the username from the Siteground SSH credentials. Will say Authenitcating with public key “whatevs” from agent. Try typing “ls” (unix command) and you can get contents of the directory. In my case this was a php_error log, tmp, and www. “ls” into the “www” directory and then deeper to get access to your site’s files.

A few Unix commands

ls (lists what’s in the directory)
cd www (puts you in the www folder)
exit is another command

If you want to completely delete this access then remove the key from pageant.exe and delete the SSH key in Siteground. Also delete the “.ppk” files from your hard drive.

SiteGround.com (No Putty)

With WordPress WP-CLI

Mentions for Windows you have PuTTY (says it sucks), can also use ssh.exe (all on command line, no gui like with putty) or a third option is Windows subsystem for linux (WSL is the author’s favorite).

Note: from docs.miscrosoft.com, The Windows Subsystem for Linux lets developers run a GNU/Linux environment — including most command-line tools, utilities, and applications — directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.

Traversy Media Notes

SSH Overview

Secure Shell. Traffic is encrypted. SSH is the client and SSHD is the server. The server must have SSHD installed and running. Typically a Linux server.

SCP

Secure File Copy. GUI for drag and drop. WinSCP. Secure FTP, SFTP, can be setup to use something like FileZilla with SSH.

How to Authenticate

3 ways, (Password, Public/Private Key Pair (preferred), Host Based)

ssh brad@192.168.1.129

Generating keys with “ssh-keygen” command.

Note: a dot preceding a directory/folder name means it is hidden and will not been seen unless view hidden folders and files is checked.

Linux and Max are Unix based systems so SSH has been supported. Windows not so much until very recently. Windows 10 now supports native SSH, (Putty is used in older version of Windows – process described above). Git Bash and other terminal programs include the ssh command & other Unix tools.

Note: Brad even says putty is a pain in the @$$ to use before SSH and gitBash was available. Brad recommends using Git Bash.

Other

Command line tutorial on Traversy Media channel. Installs apache server with “sudo apt install apache – y” command. Create SSH keys and saves the file without a passphrase. We save the public and private key on your local machine and the public key on the server. Never use the root user for security purposes. Also a good idea to disable ability to login with root user. Will need to set up SSH keys for GitHub as well. The extra dev-ops stuff gets confusing and get more complicated then web development and coding.

Sources

Traversy Media here

Siteground here