SSH Connection Setup: Difference between revisions
mNo edit summary |
|||
Line 18: | Line 18: | ||
* [https://wiki.metalevel.tech/index.php?oldid=30758 <u>The previous version of the answer which uses RSA key</u>]. | * [https://wiki.metalevel.tech/index.php?oldid=30758 <u>The previous version of the answer which uses RSA key</u>]. | ||
{{collapse/end}} | {{collapse/end}} | ||
Generate public and private SSH keys within ''your'' '''user's''' <code>'''~/.ssh'''</code> directory at the '''local host'''. The public key must be transferred to the remote host. The private key will be used at the local host. | |||
<syntaxhighlight lang="shell" line="1" class="mlw-continue"> | |||
mkdir -m700 ~/.ssh/sshfwd | |||
ssh-keygen -t ed25519 -C 'sshfwd@local.host' -f ~/.ssh/sshfwd/id_ed25519_to_hostname -q -N '' | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="shell" line="1" class="mlw-shell-gray"> | |||
ls -la ~/.ssh/sshfwd | |||
</syntaxhighlight> | |||
<syntaxhighlight lang="bash"> | |||
total 16 | |||
drwx------ 2 <user> <user> 4096 Jul 20 21:36 . | |||
drwx------ 12 <user> <user> 4096 Jul 20 21:28 .. | |||
-rw------- 1 <user> <user> 3381 Jul 20 21:36 id_ed25519_to_hostname | |||
-rw-r--r-- 1 <user> <user> 742 Jul 20 21:36 id_ed25519_to_hostname.pub | |||
</syntaxhighlight> | |||
*<code>-q</code> - silence; <code>-N <nowiki>''</nowiki></code> - empty (without) passphrase. | |||
== References == | == References == |
Revision as of 15:51, 5 September 2022
Install SSH Server and Client
The SSH client is the software that makes an SSH connection to a remote instance. The SSH server is the software that accepts the connection no the remote instance. In case we don't need to connect to the client instance – i.e. it is laptop, we do not neet to install the server.
sudo apt install openssh-server openssh-client
When the server is installed its service is automatically enabled and started, so if we have installed both packages above, we can test whether it is operational by an SSH to the loop-back interface.
sudo apt install openssh-server openssh-client
By default within the SSH server's configuration the password login is enabled. It is much safer to use key based authentication and once it is setup and operational we can safely disable the password authentication.
Setup Key Based Authentication
First we need to generate SSH key pair . This should be done at the client's side. It is preferable to use ED25519 based key, because it is more secure and also it is faster because is much shorten especially than 4096 bit RSA key.
Generate public and private SSH keys within your user's ~/.ssh
directory at the local host. The public key must be transferred to the remote host. The private key will be used at the local host.
mkdir -m700 ~/.ssh/sshfwd
ssh-keygen -t ed25519 -C 'sshfwd@local.host' -f ~/.ssh/sshfwd/id_ed25519_to_hostname -q -N ''
ls -la ~/.ssh/sshfwd
total 16
drwx------ 2 <user> <user> 4096 Jul 20 21:36 .
drwx------ 12 <user> <user> 4096 Jul 20 21:28 ..
-rw------- 1 <user> <user> 3381 Jul 20 21:36 id_ed25519_to_hostname
-rw-r--r-- 1 <user> <user> 742 Jul 20 21:36 id_ed25519_to_hostname.pub
-q
– silence;-N ''
– empty (without) passphrase.
References
- …
- …