We have a new documentation site for cPanel & WHM! You can find our new documentation site at docs.cpanel.net.

We will continue to maintain our API documentation on this server.

Child pages
  • UAPI Functions - KnownHosts::update
Skip to end of metadata
Go to start of metadata

Description

This function updates a host's entry in the cPanel account's /home/user/.ssh/known_hosts file.

Examples  


 cPanel or Webmail Session URL
https://hostname.example.com:2083/cpsess##########/execute/KnownHosts/update?host_name=host.example.com


Note:

This example calls the UAPI function via a cPanel session. For more information, read our Guide to UAPI documentation. 

 LiveAPI PHP Class
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// update the host
$update = $cpanel->uapi(
    'KnownHosts', 'update',
     array(
        'host_name'    => 'host.example.com';
     )
);


Note:

For more information, read our Guide to the LiveAPI System.

 LiveAPI Perl Module
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# update the host
my $update = $cpliveapi->uapi(
    'KnownHosts', 'update',    {
        'host_name'    => 'host.example.com',
    }
);


Note:

For more information, read our Guide to the LiveAPI System.

 Command Line
uapi --user=username KnownHosts update host_name=host.example.com


Notes:

  • You must URI-encode values.
  • username represents your account-level username.
  • For more information and additional output options, read our Guide to UAPI documentation or run the uapi --help command. 
  • If you run CloudLinux™, you must use the full path of the uapi command:

    /usr/local/cpanel/bin/uapi


 Output (JSON)
{  
	"errors": null,
	"data": {
		"host": [{
			"host": "host.example.com",
			"key": "ssh-rsa AAAAB3NzaC1yc2AEEEEDAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9",
			"line": "host.example.com ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
			"meta": {
				"algorithm": "ssh-rsa",
				"body": "EEEEB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9\bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9",
				"md5": "b6030e39868ed0e724cea3773e014219",
				"md5-printable": "MD5:b6:03:0e:39:97:2e:d0:e7:24:ab:c3:77:3d:01:42:09",
				"sha256": "55a405bcf4e11ab5b846e58ba0bf6dabd23dcc9e367cae17cb0c91b5b3b3fc55",
				"sha256-printable": "SHA256:RPLFvPThGrW4RuWLoL9tq9I9zJ42fK3XywyRtbOz/EQ"
			}
		}]
	},
	"status": 1,
	"metadata": {},
	"messages": null
}


Note:

Use cPanel's API Shell interface (cPanel >> Home >> Advanced >> API Shell) to directly test cPanel API calls.

Parameters

ParameterTypeDescriptionPossible valuesExample
host_namestring

Required

The host to update.

A valid hostname or IP address.

host.example.com

portinteger

The SSH port to use, if the system uses a non-standard SSH port.

If you do not supply a value, the function uses the standard SSH port (22).

A valid port number.1234

Returns

ReturnTypeDescriptionPossible valuesExample
hostarray of hashesAn array of hashes of host information.Each hash contains the hostkey, and line  returns, and the meta hash.

host

string

The updated host and its associated key value.

The function returns this value in the host hash.

A valid hostname or IP address.host.example.com

key

string

The host's key.

The function returns this value in the host hash.

A valid algorithm and key.
 Click to view...
ssh-rsa AAAAB3NzaC1yc2AEEEEDAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onSzH9bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9

line

string

The host's entry in the /home/user/.ssh/known_hosts file, where user is the cPanel account username.

The function returns this value in the host hash.

A valid entry that includes the hostname or IP address, the key's algorithm, and the public key.
 Click to view...
host.example.com ssh-rsa AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

meta 

string

A hash of metadata about the host's public key.

The function returns this value in the host hash.

This hash includes the algorithmbodymd5md5-printablesha256, and sha256-printable returns.

algorithm

string

The key's algorithm.

The function returns this value in the meta hash.

A valid key algorithm.ssh-rsa

body

string

The host's public key.

The function returns this value in the meta hash.

A valid public key.
 Click to view...
EEEEB3NzaC1yc2EAAAADAQABAAABAQCsj2bNKTBSpIYDEGk9KxsGh3mySTRgMtXL583qmBpzeQ+jqCMRgBqB98u3z++J1sKlXHWfM9dyhSevkMwSbhoR8XIq/U0tCNyokEi/ueaBMCvbcTHhO7FcwzY92WK4Yt0aGROY5qX2UKSeOvuP4D6TPqKF1onrSzH9\bx9XUf2lEdWT/ia1NEKjunUqu1xOB/StKDHMoX4/OKyIzuS0q/T1zOATthvasJFoPrAjkohTyaDUz2LN5JoH839hViyEG82yB+MjcFV5MU3N1l1QL3cVUCh93xSaua1N85qivl+siMkPGbO5xR/En4iEY6K2XPASUEMaieWVNTRCtJ4S8H+9

md5

string

The key's MD5 fingerprint.

The function returns this value in the meta hash.

A valid MD5 value.b6030e39868ed0e724cea3773e014219

md5-printable

string

A human-readable version of the key's MD5 fingerprint.

The function returns this value in the meta hash.

A valid formatted MD5 value.
 Click to view...
MD5:b6:03:0e:39:97:2e:d0:e7:24:ab:c3:77:3d:01:42:09

sha256

string

The key's SHA-256 fingerprint.

The function returns this value in the meta hash.

A valid SHA-256 value.
 Click to view...
55a405bcf4e11ab5b846e58ba0bf6dabd23dcc9e367cae17cb0c91b5b3b3fc55

sha256-printable

string

A human-readable version of the key's SHA-256 fingerprint.

The function returns this value in the meta hash.

A valid formatted SHA-256 value.
 Click to view...
SHA256:RPLFvPThGrW4RuWLoL9tq9I9zJ42fK3XywyRtbOz/EQ