webvaltas

Connecting with SSH

The ssh command

bash
ssh student@server.example.vnce.eu
Part Meaning
ssh the program
user the remote account you want. On Linux, the user you are logging in as
host an IP address or a hostname. student@server.example.vnce.eu
-p 2222 the remote port, when the server is not on port 22
bash
ssh -i /path/to/key student@server.example.vnce.eu    # use a specific private key
ssh -p 2222 student@localhost       # change the port

Login sequence

bash
# 1. Make a pair (once per machine you connect FROM)
ssh-keygen -t ed25519 -C "you@example.vnce.eu"

# 2. Tell the server about your PUBLIC key (once per server)
ssh-copy-id -i ~/.ssh/id_ed25519.pub student@server.example.vnce.eu

# 3. Connect. No password from now on.
ssh student@server.example.vnce.eu

ssh-copy-id appends the public key to ~/.ssh/authorized_keys with correct permissions. On Windows it is a Unix script, not shipped with the build.

If you cannot use ssh-copy-id, the manual equivalent is:

bash
cat ~/.ssh/id_ed25519.pub | ssh student@server.example.vnce.eu "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"

An sshd that sees a group- or world-writable authorized_keys refuses to trust it, and Permission denied says nothing useful.

Where the keys live

Linux and macOS

text
~/.ssh/id_ed25519            your private key           chmod 600
~/.ssh/id_ed25519.pub        your public key            chmod 644
~/.ssh/config                per-host settings
~/.ssh/known_hosts           accepted host keys, one per server
~/.ssh/authorized_keys       on the SERVER: the public keys allowed in
~/.ssh/ssh-agent socket     or agent env vars          the running key holder

The whole directory is private:

bash
chmod 700 ~/.ssh
chmod 600 ~/.ssh/id_ed25519
Side Files
Your laptop id_ed25519 (private) and id_ed25519.pub (public)
The server authorized_keys, containing your public key

Copy the .pub file to the server, never the private one. scp ~/.ssh/id_ed25519.pub student@server.example.vnce.eu:~/ moves the right file; the private key never leaves your machine.

LaptopServerprivate keypublic keyauthorized_keys copied once

The private half signs where it sits; the public half travels. Never copy id_ed25519 without the .pub.

Windows (OpenSSH the built-in client)

Windows 10 and 11 ship OpenSSH. Private keys live in your user profile:

text
C:\Users\<YourName>\.ssh\id_ed25519            private
C:\Users\<YourName>\.ssh\id_ed25519.pub        public
C:\Users\<YourName>\.ssh\config
C:\Users\<YourName>\.ssh\known_hosts

The same structure as Linux, a different path. In PowerShell:

powershell
ssh-keygen -t ed25519 -C "you@example.vnce.eu"
notepad $HOME\.ssh\id_ed25519.pub        # copy the single line

ssh-copy-id is not available, so put the key on the server by hand:

powershell
type $HOME\.ssh\id_ed25519.pub | ssh student@server.example.vnce.eu "cat >> ~/.ssh/authorized_keys"

Or log in once with the password and paste into nano.

  • File permissions. Windows ACLs matter, not a Unix mode. If sshd runs as a Windows service with a private accounts setting and your key file is readable by other local users, key auth can fail. Keep .ssh in a normal user profile with restrictive ACLs.
  • Characters in paths matter. If your username has a space (C:\Users\student account), quote it or use $HOME\.ssh, which PowerShell resolves for you.

Which keys ssh tries

ssh offers agent-held keys, then config-named keys, then the default id_ed25519, id_ecdsa, id_rsa for the matching host:

text
debug1: Offering public key: ~/.ssh/id_ed25519 ...
debug1: Server accepts key: ...

That is one accepted offer. If the server says:

text
Received disconnect from ... : Too many authentication failures

you have more keys than the server will accept in a row. Be explicit:

bash
ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 student@server.example.vnce.eu

Every offer counts against the limit; most computers hold two or three, servers allow six.

SSH config

ssh-config
Host lab
    HostName server.example.vnce.eu
    User student
    Port 22
    IdentityFile ~/.ssh/id_ed25519

Host lab-alt
    HostName alt.example.vnce.eu
    User student
    Port 2222
    IdentityFile ~/.ssh/id_ed25519_alt

ssh lab and ssh lab-alt now connect. This is why ssh -v opens with Applying options for lab.

Check yourself — 3 questions

1. You are on Windows and ssh-copy-id is not available. What are you installing on the server, and how?

The public key line, appended to the server's ~/.ssh/authorized_keys, e.g. type $HOME\.ssh\id_ed25519.pub | ssh student@server.example.vnce.eu "cat >> ~/.ssh/authorized_keys". Permissions must be 700 on the directory and 600 on the file.

2. Too many authentication failures. What happened, and what is the quick fix?

ssh offered more keys in a row than the server allows. Offer exactly one: ssh -o IdentitiesOnly=yes -i ~/.ssh/id_ed25519 student@server.example.vnce.eu.

3. Which file sets a per-host port, user, and identity file?

~/.ssh/config. A matching Host block applies those options before the connection.