- on local machine - create ssh key-pair
mykeyfile
, mykeyfile.pub
$ ssh-keygen -q -N '' -b 4096 -f ~/.ssh/mykeyfile
- on local machine - display contents of public key (so that later you can copy/paste them into
authorized_keys
)
$ cat mykeyfile.pub
- on remote machine - create file
~/.ssh/authorized_keys
(if not already exists),
add the contents of public key as a new line into that file
$ nano ~/.ssh/authorized_keys
- on local machine - add configuration for remote-machine to local ssh-config (you can use VScode for that)
$ nano ~/.ssh/config
Host myremote <- alias
HostName my-remote-machine.lan <- hostname or ip
User myremoteuser <- user-name on remote machine
Port 22 <- (optional) ssh port of remote-machine, if not default, for example: 2222
IdentityFile ~/.ssh/mykeyfile <- path to private (!!) key, not public
- on local machine - test ssh-connection to remote machine
$ ssh -Tvvv myremote
- on local machine - connect to remote
$ ssh myremote