Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Remote Access Overview

You (the network administrator) can access a router, switch, or security device remotely using services such as DHCP, Finger, FTP, rlogin, SSH, and Telnet services. This topic shows you how to configure remote access using Telnet, SSH, FTP, and Finger services.

System Services Overview

For security reasons, remote access to the router is disabled by default. You must configure the router explicitly so that users on remote systems can access it. Users can access the router from a remote system by means of the DHCP, finger, FTP, rlogin, SSH, and Telnet services. In addition, Junos XML protocol client applications can use Secure Sockets Layer (SSL) or the Junos XML protocol-specific clear-text service, among other services.

Note:

To protect system resources, you can limit the number of simultaneous connections that a service accepts and the number of processes owned by a single user. If either limit is exceeded, connection attempts fail.

Configure Telnet Service for Remote Access to a Router or Switch

To configure the router or switch to accept Telnet as an access service, include the telnet statement at the [edit system services] hierarchy level:

By default, the router or switch supports a limited number of simultaneous Telnet sessions and connection attempts per minute.

Optionally, you can include either or both of the following statements to change the defaults:

  • connection-limit limit—Maximum number of simultaneous connections per protocol (IPV4 and IPv6). The range is from 1 through 250. The default is 75. When you configure a connection limit, the limit is applicable to the number of telnet sessions per protocol (IPv4 and IPv6). For example, a connection limit of 10 allows 10 IPv6 telnet sessions and 10 IPv4 telnet sessions.

  • rate-limit limit—Maximum number of connection attempts accepted per minute (from 1 through 250). The default is 150. When you configure a rate limit, the limit is applicable to the number of connection attempts per protocol (IPv4 and IPv6). For example, a rate limit of 10 allows 10 IPv6 telnet session connection attempts per minute and 10 IPv4 telnet session connection attempts per minute.

Configure FTP Service for Remote Access to the Router or Switch

To configure the device to accept FTP as an access service, include the ftp statement at the [edit system services] hierarchy level:

You can use passive FTP to access devices that accept only passive FTP services. All commands and statements that use FTP also accept passive FTP. Include the ftp statement at the [edit system services] hierarchy level to use either active FTP or passive FTP.

To start a passive FTP session, use pasvftp (instead of ftp ) in the standard FTP format (ftp://destination). For example:

Configure Finger Service for Remote Access to the Router

To configure the router to accept finger as an access service, include the finger statement at the [edit system services] hierarchy level:

Configure SSH Service for Remote Access to the Router or Switch

To configure the router or switch to accept SSH as an access service, include the ssh statement at the [edit system services] hierarchy level:

By default, the router or switch supports a limited number of simultaneous SSH sessions and connection attempts per minute. Use the following statements to change the defaults:

  • connection-limit limit—Maximum number of simultaneous connections per protocol (IPv4 and IPv6). The range is a value from 1 through 250. The default is 75. When you configure a connection limit, the limit is applicable to the number of SSH sessions per protocol (IPv4 and IPv6). For example, a connection limit of 10 allows 10 IPv6 SSH sessions and 10 IPv4 SSH sessions.

  • max-sessions-per-connection number—Include this statement to specify the maximum number of SSH sessions allowed per single SSH connection. This allows you to limit the number of cloned sessions tunneled within a single SSH connection. The default value is 10.

  • rate-limit limit—Maximum number of connection attempts accepted per minute (a value from 1 through 250). The default is 150. When you configure a rate limit, the limit is applicable to the number of connection attempts per protocol (IPv4 and IPv6). For example, a rate limit of 10 allows 10 IPv6 SSH session connection attempts per minute and 10 IPv4 SSH session connection attempts per minute.

  • data-limit—Data limit before renegotiating session keys (bytes)

  • time-limit—Time limit before renegotiating session keys (minutes)

By default, a user can create an SSH tunnel over a CLI session to a router running Junos OS via SSH. This type of tunnel can be used to forward TCP traffic, bypassing any firewall filters or access control lists. By bypassing firewall filters or access control lists, this type of tunnel allows access to resources beyond the router. Use the no-tcp-forwarding option to prevent a user from creating an SSH tunnel to a router via SSH.

For information about other configuration settings, see the following topics:

Configure the Root Login Through SSH

By default, users are allowed to log in to the router or switch as root through SSH when the authentication method does not require a password. To control user access through SSH, include the root-login statement at the [edit systems services ssh] hierarchy level:

allow—Allows users to log in to the router or switch as root through SSH.

deny—Disables users from logging in to the router or switch as root through SSH.

deny-password—Allows users to log in to the router or switch as root through SSH when the authentication method (for example, RSA) does not require a password.

The default is deny-password.

Configure Incoming SFTP Connections

SSH File Transfer Protocol (SFTP) is a network protocol that provides file access, file transfer, and file management over any reliable data stream. Incoming SFTP connections are disabled by default. If desired, you can globally enable incoming SFTP connections by configuring the statement sftp-server at the [edit system services ssh] hierarchy level.

Note:

Only the incoming SFTP connections are disabled by default. For example, given devices A and B, you cannot connect through SFTP from B to A by default. However, you can connect through SFTP from device B to device A if you configure sftp-server on device A.

The incoming SFTP connections are disabled by default. To enable incoming SFTP connections:

  1. Configure the sftp-server statement at the [edit system services ssh] hierarchy level:
  2. Commit the configuration.

    The sftp-server statement is now active. Therefore, the incoming SFTP connections are enabled.

Configure the SSH Protocol Version

By default, only version 2 of the SSH protocol is enabled.

To configure the router or switch to use version 2 of the SSH protocol, include the protocol-version statement and specify v2 at the [edit system services ssh] hierarchy level:

Configure the Client Alive Mechanism

The client alive mechanism is valuable when the client or server depends on knowing when a connection has become inactive. It differs from the standard keepalive mechanism because the client alive messages are sent through the encrypted channel. The client alive mechanism is not enabled by default. To enable it, configure the client-alive-count-max and client-alive-interval statements. This option applies to SSH protocol version 2 only.

In the following example, unresponsive SSH clients will be disconnected after approximately 100 seconds (20 x 5):

Configure the SSH Fingerprint Hash Algorithm

To configure the hash algorithm used by the SSH server when it displays key fingerprints, include the fingerprint-hash statement and specify md5 or sha2-256 at the [edit system services ssh] hierarchy level:

SSH Certificate-Based Authentication Overview

Starting in Junos OS and Junos OS Evolved Release 22.4R1, you can configure SSH certificate-based authentication for users and hosts. This feature lets you establish password-less SSH access for users and trust hosts without verifying key fingerprints.

Benefits of SSH Certificate-Based Authentication

  • SSH certificate-based authentication eliminates the need for users to remember and enter passwords, streamlining the login process.

  • Compared to traditional password-based approaches, SSH certificates offer stronger security. They are harder to breach with no password to guess or crack.

  • SSH certificates simplify the management of authentication keys. Instead of managing individual keys for each user and host, administrators can issue and revoke certificates from a centralized certificate authority.

Generating Signing Keys

Signing keys are specialized cryptographic keys used in SSH certificate-based authentication. The first step for configuring SSH certificate-based authentication is to generate signing keys. You can generate signing keys on any Linux/FreeBSD system. Follow these steps to generate signing keys for SSH certificate-based authentication:

  1. Run the command: ssh-keygen -f <filename_ca>. This will create a private key named <filename_ca> and a corresponding public key named <filename_ca.pub>.

  2. Log in to your Juniper device and configure the SSH trusted user certificate authority (CA) key file by executing the command: set system services ssh trusted-user-ca-key-file <path-to-public-key> and then commit the configuration.

  3. Each user can generate their own user keys using the following CLI command: ssh-keygen -t <rsa|ecdsa|ed25519>.

  4. Copy the user-created public key onto the machine that has the user certificates <filename_ca> and <filename_ca.pub>.

  5. Sign the user public key in the <filename_ca.pub> file.

Configuration

To configure SSH certificate-based authentication, use the following CLI configuration statements:

  • [system services ssh trusted-user-ca-key-file filename]—Configure the TrustedUserCAKey file at /etc/ssh/sshd_config, which contains the public keys of an SSH certificate.

  • [system services ssh host-certificate-file filename]—Configure the HostCertificate file at /etc/ssh/sshd_config, which contains the signed host certificate.

  • [system services ssh authorized-principals-file filename]—Configure the AuthorizedPrincipals file at /var/etc, which contains a list of names, one of which must appear in the certificate for it to be accepted for authentication.

  • [system services ssh authorized-principals-command program-path]—Specify a program to be used for generating the list of allowed certificate principals found in the AuthorizedPrincipals file.

Disabling SSH

If you enabled SSH and want to disable it, simply remove the ssh statement from the [edit system services] hierarchy level.

If you only want to disable external SSH, use the access-disable-external statement at the [edit system services ssh] hierarchy level.

Starting in Junos OS Release 21.4R1, Junos platforms with VM host installed have SSH enabled by default. When SSH is enabled by default, you can't disable it through the [edit system services] hierarchy like normal. Instead, you can configure a firewall filter to deny SSH access:

Step-by-Step Procedure

Follow these steps to configure a firewall filter to deny SSH access:

  1. Define the filter term 1. This term denies TCP traffic from SSH:

  2. Define the filter term 2. This term allows any traffic that isn't denied by filter term 1:

For more information about using firewall filters to disable SSH, see Example: Configure a Filter to Block Telnet and SSH Access.

The telnet Command

You can use the CLI telnet command to open a Telnet session to a remote device:

To exit the Telnet session and return to the Telnet command prompt, press Ctrl-].

To exit the Telnet session and return to the CLI command prompt, enter quit.

Table 1: CLI telnet Command Options

Option

Description

8bit

Use an 8-bit data path.

host

Open a Telnet session to the specified hostname or IP address.

inet

Force the Telnet session to an IPv4 destination.

inet6

Force the Telnet session to an IPv6 destination.

port port

Specify the port number or service name on the host.

routing-instance routing-instance-name

Use the specified routing instance for the Telnet session.

The ssh Command

You can use the CLI ssh command to use the secure shell (SSH) program to open a connection to a remote device:

Table 2 describes the ssh command options.

Table 2: CLI ssh Command Options

Option

Description

bypass-routing

Bypass the routing tables and open an SSH connection only to hosts on directly attached interfaces. If the host is not on a directly attached interface, an error message is returned.

host

Open an SSH connection to the specified hostname or IP address.

inet

Force the SSH connection to an IPv4 destination.

inet6

Force the SSH connection to an IPv6 destination.

interface source-interface

Open an SSH connection to a host on the specified interface. If you do not include this option, all interfaces are used.

routing-instance routing-instance-name

Use the specified routing instance for the SSH connection.

logical-system

Use the specified logical system for the SSH connection.

source address

Use the specified source address for the SSH connection.

v2

Force SSH to use version 2 for the connection.

Configure SSH Known Host Keys for Secure Copying of Data

Secure Shell (SSH) uses encryption algorithms to generate a host, server, and session key system that ensures secure data transfer. You can configure SSH host keys to support secure copy (SCP) as an alternative to FTP for the background transfer of data such as configuration archives and event logs. To configure SSH support for SCP, you must complete the following tasks:

  • Specify SSH known hosts by including hostnames and host key information in the Routing Engine configuration hierarchy.

  • Set an SCP URL to specify the host from which to receive data. Setting this attribute automatically retrieves SSH host key information from the SCP server.

  • Verify that the host key is authentic.

  • Accept the secure connection. Accepting this connection automatically stores host key information in the local host key database. Storing host key information in the configuration hierarchy automates the secure handshake and allows background data transfer using SCP.

Tasks to configure SSH host keys for secure copying of data are:

Configure SSH Known Hosts

To configure SSH known hosts, include the host statement, and specify hostname and host key options for trusted servers at the [edit security ssh-known-hosts] hierarchy level:

Host keys are one of the following:

  • dsa-key key—Base64 encoded Digital Signature Algorithm (DSA) key for SSH version 2.

  • ecdsa-sha2-nistp256-key key—Base64 encoded ECDSA-SHA2-NIST256 key.

  • ecdsa-sha2-nistp384-key key—Base64 encoded ECDSA-SHA2-NIST384 key.

  • ecdsa-sha2-nistp521-key key—Base64 encoded ECDSA-SHA2-NIST521 key.

  • ed25519-key key—Base64 encoded ED25519 key.

  • rsa-key key—Base64 encoded public key algorithm that supports encryption and digital signatures for SSH version 1 and SSH version 2.

  • rsa1-key key—Base64 encoded RSA public key algorithm, which supports encryption and digital signatures for SSH version 1.

Configure Support for SCP File Transfer

To configure a known host to support background SCP file transfers, include the archive-sites statement at the [edit system archival configuration] hierarchy level.

Note:

When specifying a URL in a Junos OS Evolved statement using an IPv6 host address, you must enclose the entire URL in quotation marks (" ") and enclose the IPv6 host address in brackets ([ ]). For example, “scp://username<:password>@[host]<:port>/url-path”;

Setting the archive-sites statement to point to an SCP URL triggers automatic host key retrieval. At this point, Junos OS Evolved connects to the SCP host to fetch the SSH public key, displays the host key message digest or fingerprint as output to the console, and terminates the connection to the server.

To verify that the host key is authentic, compare this fingerprint with a fingerprint that you obtain from the same host using a trusted source. If the fingerprints are identical, accept the host key by entering yes at the prompt. The host key information is then stored in the Routing Engine configuration and supports background data transfers using SCP.

Update SSH Host Key Information

Typically, SSH host key information is automatically retrieved when you set a URL attribute for SCP using the archival configuration archive-sites statement at the [edit system] hierarchy level. However, if you need to manually update the host key database, use one of the following methods.

Retrieve Host Key Information Manually

To manually retrieve SSH public host key information, configure the fetch-from-server option at the [edit security ssh-known-hosts] hierarchy level. You must to specify the host from which to retrieve the SSH public key.

Import Host Key Information from a File

To manually import SSH host key information from a known_hosts file, include the load-key-file option at the [edit security ssh-known-hosts] hierarchy level. You must specify the path to the file from which to import host key information.

Configure the SSH Service to Support Legacy Cryptography

The SSH server in Junos OS Evolved is based on OpenSSH 7 and defaults to a more secure set of ciphers and key-exchange algorithms. OpenSSH 7 omits some legacy cryptography.

Note:

See the OpenSSH 7 documentation at https://www.openssh.com/ for more information about these extensions.

Junos OS Evolved supports the following set of ciphers by default:

  • chacha20-poly1305@openssh.com

  • aes128-ctr

  • aes192-ctr

  • aes256-ctr

  • aes128-gcm@openssh.com

  • aes256-gcm@openssh.com

In Junos OS Evolved, the following ciphers are not supported by default, but you can configure your device to support them. They are listed from the most secure to the least secure:

  • aes256-cbc

  • aes192-cbc

  • aes128-cbc

Junos OS Evolved supports the following set of key-exchange methods by default:

  • curve25519-sha256

  • ecdh-sha2-nistp256

  • ecdh-sha2-nistp384

  • ecdh-sha2-nistp521

  • group-exchange-sha2

  • dh-group14-sha1

In Junos OS Evolved, the following key-exchange methods are not supported by default, but you can configure your device to support them:

  • group-exchange-sha1

  • dh-group1-sha1

To configure the SSH service to support legacy cryptography:

Note:

By configuring an ordered set of ciphers, key-exchange methods, or message authentication codes (MACs), the newly defined set is applied to both server and client commands. Changes to the defaults affect the file copy command when you use Secure Copy Protocol (SCP).

  1. Add support for ciphers by using the set system services ssh ciphers [ cipher 1 cipher 2 ... ] command. We recommend that you add the ciphers to the end of the configuration list so that they are among the last options used. In the following example, the arcfour and blowfish-cbc ciphers are added to the default set:
  2. Add support for key-exchange methods by using the set system services ssh key-exchange [ method 1 method 2 ... ] command. We recommend that you add the key-exchange methods to the end of the configuration list so that they are among the last options used. In the following example, the dh-group1-sha1 key-exchange method is added to the default set:
  3. Commit the configuration:

Configure Outbound SSH Service

You can configure a device running Junos OS Evolved to initiate a TCP/IP connection with a client management application. If the management application does not reach a Juniper Networks device, for example, the device being a firewall. In such cases, outbound-ssh can be configured on the Juniper Networks device. An outbound-ssh configuration initiates a reverse SSH connection from server to client to the management application. This outbound SSH connection is closed only after the configuration are removed from the device.

Note:

There is no initiation command with outbound SSH. After you configure and commit outbound SSH, the device begins to initiate an outbound SSH connection based on the committed configuration. The device repeatedly attempts to create this connection until successful. If the connection between the device and the client management application is dropped, the device again attempts to create a new outbound SSH connection until successful. This connection is maintained until the outbound SSH stanza is removed from the configuration.

To configure the device for outbound SSH connections, include the outbound-ssh statement at the [edit system services] hierarchy level:

[edit system services outbound-ssh]

The following topics describe the tasks for configuring the outbound SSH service.

Send the Public SSH Host Key to the Outbound SSH Client

Each time the router or switch establishes an outbound SSH connection, it first sends an initiation sequence to the management client. This sequence identifies the router or switch to the management client. Within this transmission is the value of device-id.

To configure the device identifier of the router or switch, include the device-id statement at the [edit system services outbound-ssh client client-id] hierarchy level:

The initiation sequence when secret is not configured:

During the initialization of an SSH connection, the client authenticates the identity of the device using the public SSH host key of the device. Therefore, before the client can initiate the SSH sequence, the client needs the public SSH key of the device. When you configure the secret statement, the device passes its public SSH key as part of the outbound SSH connection initiation sequence.

When the secret statement is set and the device establishes an outbound SSH connection, the device communicates its device ID, its public SSH key, and an SHA1 hash derived in part from the secret statement. The value of the secret statement is shared between the device and the management client. The client uses the shared secret to authenticate the public SSH host key it is receiving to determine whether the public key is from the device identified by the device-id statement.

Using the secret statement to transport the public SSH host key is optional. You can manually transport and install the public key onto the client system.

Note:

Including the secret statement means that the device sends its public SSH host key every time it establishes a connection to the client. It is then up to the client to decide what to do with the SSH host key if the client already has an SSH key for that device. We recommend that you replace the client’s copy of the SSH host key with the new key. Host keys can change for various reasons. By replacing the key each time a connection is established, you ensure that the client has the latest key.

To send the router’s or switch’s public SSH host key when the device connects to the client, include the secret statement at the [edit system services outbound-ssh client client-id] hierarchy level:

The following message is sent by the device when the secret attribute is configured:

Configure Keepalive Messages for Outbound SSH Connections

After the client application has the router’s or switch’s public SSH host key, it can initiate the SSH sequence as if it had created the TCP/IP connection. The client can then authenticate the device using its copy of the router’s or switch’s public host SSH key as part of that sequence. The device authenticates the client user through the mechanisms supported in Junos OS Evolved (RSA/DSA public string or password authentication).

To enable the device to send SSH protocol keepalive messages to the client application, configure the keep-alive statement at the [edit system services outbound-ssh client client-id] hierarchy level:

Configure a New Outbound SSH Connection

When disconnected, the device begins to initiate a new outbound SSH connection. To specify how the device reconnects to the server after a connection is dropped, include the reconnect-strategy statement at the [edit system services outbound-ssh client client-id] hierarchy level:

You can also specify the number of retry attempts and set the amount of time before the reconnection attempts stop. See Configure Keepalive Messages for Outbound SSH Connections.

Configure the Outbound SSH Client to Accept NETCONF as an Available Service

To configure the application to accept NETCONF as an available service, include the services netconf statement at the [edit system services outbound-ssh client client-id] hierarchy level:

Configure Outbound SSH Clients

To configure the clients available for this outbound SSH connection, list each client with a separate address statement at the [edit system services outbound-ssh client client-id] hierarchy level:

Note:

Outbound SSH connections support IPv4 and IPv6 address formats.

Configure Routing Instances for Outbound SSH Clients

To use the management routing instance, first enable the mgmt_junos routing instance using the set system management-instance command.

To use any other routing instance, first configure the routing instance at the [edit routing-instances] hierarchy.

If you do not specify a routing instance, your device will establish the outbound SSH connection using the default routing table.

Configure NETCONF-Over-SSH Connections on a Specified TCP Port

Junos OS Evolved enables you to restrict incoming NETCONF connections to a specified TCP port without configuring a firewall. To configure the TCP port used for NETCONF-over-SSH connections, include the port statement at the [edit system services netconf ssh] hierarchy level. The configured port accepts only NETCONF-over-SSH sessions. Regular SSH session requests for this port are rejected.

You can either configure the default port 830 for NETCONF connections over SSH, as specified in RFC 4742, Using the NETCONF Configuration Protocol over Secure Shell (SSH), or configure any port from 1 through 65535.

Note:
  • The default SSH port (22) continues to accept NETCONF sessions even with a configured NETCONF server port. To disable the SSH port from accepting NETCONF sessions, specify this in the login event script.

  • We do not recommend configuring the default ports for FTP (21) and Telnet (23) services for configuring NETCONF-over-SSH connections.