This isn’t really a step in the MSNR process but more notes for myself in the future so when I build another server I know what to do and not have to do everything over again from scratch.
Well your not gonna stand in front of your server all day while you code are you? Well I’m not (not that dedicated). Today I want to cover the basics of getting openSSH installed, configured and connecting to your files over SFTP.
I’m on windows so it was actually a bit of an ordeal the first time.
- If you don’t have it go download Putty.
- Next, generate an SSH Key:
- Open the PuTTYgen program.
- For Type of key to generate, select SSH-2 RSA.
- Click the Generate button.
- Move your mouse in the area below the progress bar. When the progress bar is full, PuTTYgen generates your key pair.
- Type a passphrase in the Key passphrase field.
- Type the same passphrase in the Confirm passphrase field. You can use a key without a passphrase, but this is not recommended.
- Save your private key.
- Select your public key and paste it into a new text file
- You can use the saved one on openSSH Putty will format it wrong
- Now that you got your keys comes the fun part get the public key on your server.
- Copy your text file with the pasted key on to a jump drive.
- Plug that into your server
- Once you plug it in you’ll notice that Ubuntu recognized it and probably set it to something like [sda]
- Now for the commands
//Mount your USB drive sudo mkdir /media/usb sudo mount /dev/sda1 /media/usb //Yours might just be /dev/sda //Create your authorized keys file cd ~ //If your not already there sudo mkdir .ssh sudo chmod 700 .ssh cd .ssh sudo touch authorized_keys sudo chmod 600 authorized_keys //Now we'll add your key (from the file on your jump drive) to our authorized_keys file sudo cat /media/usb/mypublickey.txt >> authorized_keys //Now unmount your jump drive sudo umount /meida/usb //Remvoe your jump drive & restart SSH sudo restart ssh
Now you should be able to create your connection to your server. Open up Putty type in the IP of your server then go to the Connection >> SSH >> Auth and put the location of your Private key that you saved earlier in the “Private key file for authentication:” field.
There you are SSH done. Finally to connect to your folder via SFTP (I use Filezilla). First load your private key file into Filezilla and open up Edit >> Settings. Now go to the SFTP section and add your private key file again. If you used a passphrase you’ll have to enter it in and save another version of your keyfile with out a passphrase. Add the keyfile and create your new connection. Use your username and the IP and you should be good to go.
Happy coding.