This is a quick guide that will show you how you can connect to a cloud server via SFTP with the PHPStorm IDE from Jet Brians and deploy files from your localhost to the cloud
Below is the way I connect to a remote server via SSH keys generated on OSX.
Setting up a server
When you set up an Ubuntu server on Vultr (read my guide on setting up a Vultr server for as low as $2.5 a month) or Digital Ocean (use this link to get two months free when you setup an Ubuntu server on digital ocean) you can specify an SSH key to use for remote connections during the server create stage (old guide here).
How to create an SSH key on OSX to use to connect to a remote server
Run the following command (“sudo ssh-keygen -t rsa“) to generate an ssh key paid in “~/.ssh/” on OSX.
cd ~/.ssh/ sudo ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/var/root/.ssh/id_rsa): test.rsa Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in test.rsa. Your public key has been saved in test.rsa.pub. The key fingerprint is: SHA256:sJtlhWremoved2IUp8 [email protected] The key's randomart image is (edited): +---[RSA 2048]----+ | . +o=+. | | . o + =.o.. | | . . + o *o+ . | | . E B +.= | | o S = +. | | O o..+ o | | * . .o * . | | o ..* | | ..+.. | +----[SHA256]-----+
TIP: It is a good idea to also generate a passphrase to use with the key (double protection). You will be prompted to enter this password to use the RSA key.
You can now see the generated keys in ~/.ssh/
ls test* -al total 224 drwxr-xr-x+ 29 username staff 928 26 Nov 17:07 . [email protected] 89 username staff 2848 25 Nov 19:03 .. ... -rw------- 1 username staff 1766 26 Nov 17:07 test.rsa -rw-r--r-- 1 username staff 412 26 Nov 17:07 test.rsa.pub ...
You can view the contents of the public file (you can use this when generating Digital Ocean, Vultr, AWS or Azure or other cloud servers).
fyi: Replace 126.96.36.199 with your remote serves ip.
sudo cat /~.ssh/test.rsa.pub ssh-rsa AAAAB3NzaC...removed...1RL5hCG0lUn 188.8.131.52
How to connect to a server (the old way).
As long as your host added the desired public ssh key file contents to the server (adding the public ssh key contents to “~/.ssh/authorized_keys” you will be able to connect to the server.
Run the following command on OSX command line to connect to the server via SSH.
sudo ssh -i ~/.ssh/test.rsa [email protected]
You should see..
Enter passphrase for key '/Users/username/.ssh/test.rsa': > PASSPHRASECREATEDEARLIER Welcome to Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-101-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage Get cloud support with Ubuntu Advantage Cloud Guest: http://www.ubuntu.com/business/services/cloud 0 packages can be updated. 0 updates are security updates. Last login: Sun Nov 26 08:47:20 2017 from 184.108.40.206 [email protected]:~# ls -al total 32 drwx------ 5 remoteuser remoteuser 4096 Nov 25 12:07 . drwxr-xr-x 24 remoteuser remoteuser 4096 Nov 25 12:15 .. -rw------- 1 remoteuser remoteuser 1813 Nov 26 08:57 .bash_history -rw-r--r-- 1 remoteuser remoteuser 3106 Oct 22 2015 .bashrc ...
Congratulations, you should now be able to connect to your server via SSH.
Securing your ubuntu Server
Don’t forget to add a firewall and set up an SSL certificate.
How to connect to a server (faster way).
todo: ~/.ssh/config method
Now we can connect to your remote server with the shorter method.
todo: ~/.ssh/config method
Donate and make this blog better
Ask a question or recommend an article
v1.0 Initial Post