Skip to main content

Managing SSH Keys

Managing SSH keys for secure access to servers in Arvancloud Cloud Server.

Overview​

The ssh-key commands provide tools for managing the SSH public keys used for secure authentication on cloud servers. SSH keys are a more secure alternative to traditional passwords.

Alias: ssh

Commands​

1. Listing SSH Keys​

Shows the list of all SSH keys registered in the account.

arvan iaas ssh-key list

Alias: ls

Flags:

  • --region, -r: filter by region code (such as ir-central1)
  • --az, -a: filter by data center (such as ir-central1-a)

Example:

$ arvan iaas ssh-key list --region=ir-central1

Output:

NAME FINGERPRINT AZ
my-laptop-key a1:b2:c3:d4:e5:f6:01:23:45:67:89:ab:cd:ef:01:23 ir-central1-a
production-key b2:c3:d4:e5:f6:01:23:45:67:89:ab:cd:ef:01:23:45 ir-central1-a
backup-key c3:d4:e5:f6:01:23:45:67:89:ab:cd:ef:01:23:45:67 ir-central1-b

2. Showing SSH Key Details​

Shows detailed information about a specific SSH key.

arvan iaas ssh-key show <ssh-key-name>

Alias: sh

Arguments:

  • ssh-key-name (required): the SSH key name

Example:

$ arvan iaas ssh-key show my-laptop-key

Output:

SSH KEY DETAILS
---------------
Name: my-laptop-key
Fingerprint: a1:b2:c3:d4:e5:f6:01:23:45:67:89:ab:cd:ef:01:23
AZ: ir-central1-a
Created: 2025-01-05T14:30:00Z


PUBLIC KEY
----------
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQC8yN9xKzJ2... user@laptop

3. Adding an SSH Key​

Adds a new SSH key to the account.

arvan iaas ssh-key add <name>

Arguments:

  • name (required): a name for the SSH key

Flags:

  • --public-key, -k: the content of the public key
  • --key-file, -f: the path to the public key file (such as ~/.ssh/id_rsa.pub)
  • --az, -a: the data center to add the key to (required)

You must enter one of the two flags --public-key or --key-file.

Example (using a file path):

$ arvan iaas ssh-key add workstation-key --key-file=~/.ssh/id_rsa.pub --az=ir-central1-a

Output:

SSH KEY ADDED
-------------
Name: workstation-key
Fingerprint: d4:e5:f6:01:23:45:67:89:ab:cd:ef:01:23:45:67:89
AZ: ir-central1-a

SSH key added successfully!
You can now use this key when creating servers.

4. Deleting an SSH Key​

Deletes an SSH key from the account.

arvan iaas ssh-key delete <ssh-key-name>

Alias: del

Arguments:

  • ssh-key-name (required): the name of the SSH key to delete

Example:

$ arvan iaas ssh-key delete backup-key

Output:

SSH KEY TO DELETE
-----------------
Name: backup-key
Fingerprint: c3:d4:e5:f6:01:23:45:67:89:ab:cd:ef:01:23:45:67
AZ: ir-central1-b

Are you sure you want to delete SSH key 'backup-key'? (y/n) y

SSH key deleted successfully!

Working with SSH Keys​

Creating a New SSH Key Pair​

If you don't have an SSH key pair, you can create one with the ssh-keygen command:

ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f ~/.ssh/arvan_rsa

This command creates two files:

  • Private key: ~/.ssh/arvan_rsa (keep this file in a secure place)
  • Public key: ~/.ssh/arvan_rsa.pub (upload this file to Arvancloud)

Using an SSH Key When Creating a Server​

When creating a server, specify the name of your SSH key:

arvan iaas server create --name=web-server \
--flavor=g1-2-4 \
--image=img-ubuntu2204 \
--az=ir-central1-a \
--ssh-key=my-key

Connecting to the Server​

After creating a server with an SSH key, connect to it like this:

ssh -i ~/.ssh/arvan_rsa ubuntu@<server-ip>

The username depends on the operating system:

  • Ubuntu/Debian: ubuntu
  • CentOS/RHEL: centos or cloud-user
  • Fedora: fedora

Security Recommendations​

  • Use strong keys: use 4096-bit RSA keys or Ed25519 keys for more security.
  • Unique keys: use different keys for different purposes (such as development and operations).
  • Secure storage: never share your private key, and restrict its file permissions (chmod 600).
  • Good naming: use descriptive names so keys are easy to identify (such as prod-web-server).
  • Regular rotation: rotate your keys regularly to stay secure.

Troubleshooting​

  • Permission Denied (publickey) error:
    • Make sure you're using the correct private key.
    • Check that the public key has been added correctly in Arvancloud.
    • Check the private key's permissions: chmod 600 ~/.ssh/your_key.
  • Key Already Exists error:
    • Each key name must be unique within a data center. Choose another name or delete the previous key.
  • Can't Read Key File error:
    • Check that the file path is correct and that the file can be read.

Command Reference​

CommandAliasDescriptionArguments
ssh-key listlsList all SSH keysNone
ssh-key showshShow the details of a specific key<ssh-key-name>
ssh-key add-Add a new SSH key<name>
ssh-key deletedelDelete an SSH key<ssh-key-name>