It feels better and gains desire to code when it’s easy to access your server via SSH with no IP limitation and password. Using public/private keys is a good way. And it’s easy!
Let’s say we have a Linux as a server and a Mac as a client where you do your work.
Connect to server via SSH On Mac
On the Mac (client)
- Open Terminal
- Go to .ssh directory:
if there isn’t a .ssh directory,
cd ~and then
- See if you already have a key pair by
ls. (see if there are id_dsa and id_dsa.pub)
If you do then
vi id_dsa.puband copy everything inside and
:qto quit vi editor
If you don’t then do
ssh-keygenand enter, you’ll see something like this:> Generating public/private rsa key pair.
Enter file in which to save the key (/home/jsmith/.ssh/id_rsa):[Enter key]
Enter passphrase (empty for no passphrase): [Press enter key]
Enter same passphrase again: [Pess enter key]
Your identification has been saved in /home/jsmith/.ssh/id_rsa.
Your public key has been saved in /home/jsmith/.ssh/id_rsa.pub.
The key fingerprint is:
On the server
- Open authorized_keys in .ssh directory:
ito edit, paste the content from id_dsa.pub, press
escto finish editing then save and quit using
- here‘s an advanced way to do this!