Skip to main content

Using ~/.ssh/config

Give your machine a short name in your SSH config, with its host, port and user, so ssh, scp, rsync and VS Code work without long commands.

On this page

Your SSH client reads a config file where you can give a host a short name and remember its options. With an entry for your reservation, ssh gpu replaces ssh -p 2211 renter@ssh.gputorent.com, and the same name works with scp, rsync and VS Code's Remote-SSH.

Where the file is

  • macOS and Linux: ~/.ssh/config
  • Windows: C:\Users\<you>\.ssh\config (no file extension)

Create it if it doesn't exist. On macOS and Linux, keep it private:

bash
touch ~/.ssh/config
chmod 600 ~/.ssh/config

Add your machine

Take the port from the SSH command on your reservation page. For ssh -p 2211 renter@ssh.gputorent.com, add:

ssh-config
Host gpu
    HostName ssh.gputorent.com
    Port 2211
    User renter
    IdentityFile ~/.ssh/id_ed25519
    IdentitiesOnly yes
    ServerAliveInterval 30
  • Host is the short name you'll type.
  • HostName is the same for every machine: ssh.gputorent.com.
  • Port is your machine's own SSH port. It's never 22.
  • User is always renter.
  • IdentityFile is your private key: the file without .pub.
  • IdentitiesOnly yes makes SSH offer only that key, which avoids "Too many authentication failures" when your agent holds many keys.
  • ServerAliveInterval 30 keeps an idle connection from being dropped by routers along the way.

Now connect with:

bash
ssh gpu

And copy files with the same name, no port flags needed:

bash
scp ./data.zip gpu:~/
rsync -avP ./data/ gpu:~/data/

Two machines at once

Give each reservation its own name and port. For example, a Mac Studio and a DGX Spark:

ssh-config
Host gpu
    HostName ssh.gputorent.com
    Port 2211
    User renter
    IdentityFile ~/.ssh/id_ed25519

Host spark
    HostName ssh.gputorent.com
    Port 2201
    User renter
    IdentityFile ~/.ssh/id_ed25519

Port forwarding in the config

To forward a port every time you connect, for example Jupyter on port 8888 and a model server on port 8080:

ssh-config
Host gpu
    HostName ssh.gputorent.com
    Port 2211
    User renter
    IdentityFile ~/.ssh/id_ed25519
    LocalForward 8888 localhost:8888
    LocalForward 8080 localhost:8080

While ssh gpu is connected, http://localhost:8888 and http://localhost:8080 reach those ports on the machine. See VS Code and Jupyter.

Host keys

SSH stores one host key per [ssh.gputorent.com]:port, so each machine has its own entry in ~/.ssh/known_hosts, whichever Host name you use. A machine keeps its host key from one rental to the next. If SSH ever warns that the host key changed, see Troubleshooting.

After your reservation

Your next reservation may be on another machine with a different port. Check the port on the new reservation page and update Port in your entry; the rest stays the same.