Open Ssh Config File

Posted : admin On 1/3/2022


Originally posted at Prerequisite GitLab account macOS If you want to. Tagged with git, gitlab, macos. OpenSSH allows you to set up a per-user configuration file where you can store different SSH options for each remote machine you connect to. This guide covers the basics of the SSH client. SSH Config Editor is a handy tool for manage your OpenSSH ssh client configuration file. You can add or edit identity files, port forwardings (with handy. I installed Git-1.7.9-preview20120201.exe, and when I try to access my repository via SSH it failed. I investigated and found that if I run SSH -T [email protected], SSH doesn't load /.ssh/config where a custom port is defined. When I try SSH -F c:userstomas.sshconfig [email protected] everything is OK.

ssh_config - OpenSSH SSH client configuration files





ssh(1) obtains configuration data from the following sources in the following order:

2. user's configuration file (~/.ssh/config)
3. system-wide configuration file (/etc/ssh/ssh_config)

For each parameter, the first obtained value will be used. The configuration files contain sections separated by 'Host' specifications, and that sectionis only applied for hosts that match one of the patterns given in the specification. The matched host name is the one given on the command line.

Since the first obtained value for each parameter is used, more host-specific declarations should be given near the beginning of the file, and generaldefaults at the end.

The configuration file has the following format:

Empty lines and lines starting with '#' are comments. Otherwise a line is of the format 'keyword arguments'. Configuration options may be separated bywhitespace or optional whitespace and exactly one '='; the latter format is useful to avoid the need to quote whitespace when specifying configuration optionsusing the ssh, scp, and sftp -o option. Arguments may optionally be enclosed in double quotes (') in order to represent argumentscontaining spaces.

The possible keywords and their meanings are as follows (note that keywords are case-insensitive and arguments are case-sensitive):

Host' Restricts the following declarations (up to the next Host keyword) to be only for those hosts that match one of the patterns given afterthe keyword. If more than one pattern is provided, they should be separated by whitespace. A single '*' as a pattern can be used to provide global defaults forall hosts. The host is the hostname argument given on the command line (i.e. the name is not converted to a canonicalized host name before matching).

See PATTERNS for more information on patterns.

Specifies which address family to use when connecting. Valid arguments are 'any', 'inet' (use IPv4 only), or 'inet6' (use IPv6 only).

If set to 'yes', passphrase/password querying will be disabled. This option is useful in scripts and other batch jobs where no user is present to supply thepassword. The argument must be 'yes' or 'no'. The default is 'no'.

Use the specified address on the local machine as the source address of the connection. Only useful on systems with more than one address. Note that thisoption does not work if UsePrivilegedPort is set to 'yes'.

Specifies whether to use challenge-response authentication. The argument to this keyword must be 'yes' or 'no'. The default is 'yes'.

If this flag is set to 'yes', ssh(1) will additionally check the host IP address in the known_hosts file. This allows ssh to detect if a host keychanged due to DNS spoofing. If the option is set to 'no', the check will not be executed. The default is 'yes'.

Specifies the cipher to use for encrypting the session in protocol version 1. Currently, 'blowfish', '3des', and 'des' are supported. des is onlysupported in the ssh(1) client for interoperability with legacy protocol 1 implementations that do not support the 3des cipher. Its use is stronglydiscouraged due to cryptographic weaknesses. The default is '3des'.

Specifies the ciphers allowed for protocol version 2 in order of preference. Multiple ciphers must be comma-separated. The supported ciphers are '3des-cbc','aes128-cbc', 'aes192-cbc', 'aes256-cbc', 'aes128-ctr', 'aes192-ctr', 'aes256-ctr', 'arcfour128', 'arcfour256', 'arcfour', 'blowfish-cbc',and 'cast128-cbc'. The default is:


Specifies that all local, remote, and dynamic port forwardings specified in the configuration files or on the command line be cleared. This option isprimarily useful when used from the ssh(1) command line to clear port forwardings set in configuration files, and is automatically set by scp(1) and sftp(1).The argument must be 'yes' or 'no'. The default is 'no'.

Specifies whether to use compression. The argument must be 'yes' or 'no'. The default is 'no'.

Specifies the compression level to use if compression is enabled. The argument must be an integer from 1 (fast) to 9 (slow, best). The default level is 6,which is good for most applications. The meaning of the values is the same as in gzip(1). Note that this option applies to protocol version 1 only.

Specifies the number of tries (one per second) to make before exiting. The argument must be an integer. This may be useful in scripts if the connectionsometimes fails. The default is 1.

Specifies the timeout (in seconds) used when connecting to the SSH server, instead of using the default system TCP timeout. This value is used only when thetarget is down or really unreachable, not when it refuses the connection.

Enables the sharing of multiple sessions over a single network connection. When set to 'yes', ssh(1) will listen for connections on a control socketspecified using the ControlPath argument. Additional sessions can connect to this socket using the same ControlPath with ControlMaster setto 'no' (the default). These sessions will try to reuse the master instance's network connection rather than initiating new ones, but will fall back toconnecting normally if the control socket does not exist, or is not listening.

Setting this to 'ask' will cause ssh to listen for control connections, but require confirmation using the SSH_ASKPASS program before they are accepted(see ssh-add(1) for details). If the ControlPath cannot be opened, ssh will continue without connecting to a master instance.

X11 and ssh-agent(1) forwarding is supported over these multiplexed connections, however the display and agent forwarded will be the one belonging to themaster connection i.e. it is not possible to forward multiple displays or agents.

Two additional options allow for opportunistic multiplexing: try to use a master connection but fall back to creating a new one if one does not alreadyexist. These options are: 'auto' and 'autoask'. The latter requires confirmation like the 'ask' option.

Specify the path to the control socket used for connection sharing as described in the ControlMaster section above or the string 'none' to disableconnection sharing. In the path, '%l' will be substituted by the local host name, '%h' will be substituted by the target host name, '%p' the port, and '%r' bythe remote login username. It is recommended that any ControlPath used for opportunistic connection sharing include at least %h, %p, and %r. Thisensures that shared connections are uniquely identified.

Specifies that a TCP port on the local machine be forwarded over the secure channel, and the application protocol is then used to determine where to connect tofrom the remote machine.

The argument must be [
:]port. IPv6 addresses can be specified by enclosing addresses in square brackets or by using an alternative syntax: [
/]port. By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_addressmay be used to bind the connection to a specific address. The bind_address of 'localhost' indicates that the listening port be bound for local useonly, while an empty address or '*' indicates that the port should be available from all interfaces.

Currently the SOCKS4 and SOCKS5 protocols are supported, and ssh(1) will act as a SOCKS server. Multiple forwardings may be specified, and additionalforwardings can be given on the command line. Only the superuser can forward privileged ports.

Setting this option to 'yes' in the global client configuration file /etc/ssh/ssh_config enables the use of the helper program ssh-keysign(8) duringHostbasedAuthentication. The argument must be 'yes' or 'no'. The default is 'no'. This option should be placed in the non-hostspecific section.See ssh-keysign(8) for more information.

Sets the escape character (default: '~'). The escape character can also be set on the command line. The argument should be a single character, '^' followed bya letter, or 'none' to disable the escape character entirely (making the connection transparent for binary data).

Specifies whether ssh(1) should terminate the connection if it cannot set up all requested dynamic, tunnel, local, and remote port forwardings. The argumentmust be 'yes' or 'no'. The default is 'no'.

Specifies whether the connection to the authentication agent (if any) will be forwarded to the remote machine. The argument must be 'yes' or 'no'. Thedefault is 'no'.

Agent forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the agent's Unix-domain socket)can access the local agent through the forwarded connection. An attacker cannot obtain key material from the agent, however they can perform operations on thekeys that enable them to authenticate using the identities loaded into the agent.

Specifies whether X11 connections will be automatically redirected over the secure channel and DISPLAY set. The argument must be 'yes' or 'no'. The defaultis 'no'.

X11 forwarding should be enabled with caution. Users with the ability to bypass file permissions on the remote host (for the user's X11 authorizationdatabase) can access the local X11 display through the forwarded connection. An attacker may then be able to perform activities such as keystroke monitoring ifthe ForwardX11Trusted option is also enabled.

If this option is set to 'yes', remote X11 clients will have full access to the original X11 display.

If this option is set to 'no', remote X11 clients will be considered untrusted and prevented from stealing or tampering with data belonging to trusted X11clients. Furthermore, the xauth(1) token used for the session will be set to expire after 20 minutes. Remote clients will be refused access after this time.

The default is 'no'.

See the X11 SECURITY extension specification for full details on the restrictions imposed on untrusted clients.

Specifies whether remote hosts are allowed to connect to local forwarded ports. By default, ssh(1) binds local port forwardings to the loopback address. Thisprevents other remote hosts from connecting to forwarded ports. GatewayPorts can be used to specify that ssh should bind local port forwardings to thewildcard address, thus allowing remote hosts to connect to forwarded ports. The argument must be 'yes' or 'no'. The default is 'no'.

Specifies a file to use for the global host key database instead of /etc/ssh/ssh_known_hosts.

Specifies whether user authentication based on GSSAPI is allowed. The default is 'no'. Note that this option applies to protocol version 2 only.

Specifies whether key exchange based on GSSAPI may be used. When using GSSAPI key exchange the server need not have a host key. The default is 'no'. Notethat this option applies to protocol version 2 only.

If set, specifies the GSSAPI client identity that ssh should use when connecting to the server. The default is unset, which means that the default identitywill be used.

Forward (delegate) credentials to the server. The default is 'no'. Note that this option applies to protocol version 2 connections using GSSAPI.

Ssh Config File Password

If set to 'yes' then renewal of the client's GSSAPI credentials will force the rekeying of the ssh connection. With a compatible server, this can delegatethe renewed credentials to a session on the server. The default is 'no'.

Set to 'yes to indicate that the DNS is trusted to securely canonicalize' the name of the host being connected to. If 'no, the hostname entered on the'command line will be passed untouched to the GSSAPI library. The default is 'no'. This option only applies to protocol version 2 connections using GSSAPI.

Indicates that ssh(1) should hash host names and addresses when they are added to ~/.ssh/known_hosts. These hashed names may be used normally by ssh(1)and sshd(8), but they do not reveal identifying information should the file's contents be disclosed. The default is 'no'. Note that existing names andaddresses in known hosts files will not be converted automatically, but may be manually hashed using ssh-keygen(1).

Specifies whether to try rhosts based authentication with public key authentication. The argument must be 'yes' or 'no'. The default is 'no'. This optionapplies to protocol version 2 only and is similar to RhostsRSAAuthentication.

Specifies the protocol version 2 host key algorithms that the client wants to use in order of preference. The default for this option is: 'ssh-rsa,ssh-dss'.

Specifies an alias that should be used instead of the real host name when looking up or saving the host key in the host key database files. This option isuseful for tunneling SSH connections or for multiple servers running on a single host.

Specifies the real host name to log into. This can be used to specify nicknames or abbreviations for hosts. The default is the name given on the command line.Numeric IP addresses are also permitted (both on the command line and in HostName specifications).

Specifies that ssh(1) should only use the authentication identity files configured in the ssh_config files, even if ssh-agent(1) offers more identities.The argument to this keyword must be 'yes' or 'no'. This option is intended for situations where ssh-agent offers many different identities. The default is'no'.

Specifies a file from which the user's RSA or DSA authentication identity is read. The default is ~/.ssh/identity for protocol version 1, and~/.ssh/id_rsa and ~/.ssh/id_dsa for protocol version 2. Additionally, any identities represented by the authentication agent will be used forauthentication.

The file name may use the tilde syntax to refer to a user's home directory or one of the following escape characters: '%d' (local user's home directory),'%u' (local user name), '%l' (local host name), '%h' (remote host name) or '%r' (remote user name).

It is possible to have multiple identity files specified in configuration files; all these identities will be tried in sequence.

Specifies whether to use keyboard-interactive authentication. The argument to this keyword must be 'yes' or 'no'. The default is 'yes'.

Specifies the list of methods to use in keyboard-interactive authentication. Multiple method names must be comma-separated. The default is to use the serverspecified list. The methods available vary depending on what the server supports. For an OpenSSH server, it may be zero or more of: 'bsdauth', 'pam', and'skey'.

Specifies a command to execute on the local machine after successfully connecting to the server. The command string extends to the end of the line, and isexecuted with the user's shell. The following escape character substitutions will be performed: '%d' (local user's home directory), '%h' (remote host name),'%l' (local host name), '%n' (host name as provided on the command line), '%p' (remote port), '%r' (remote user name) or '%u' (local user name). This directiveis ignored unless PermitLocalCommand has been enabled.

Specifies that a TCP port on the local machine be forwarded over the secure channel to the specified host and port from the remote machine. The first argumentmust be [
:]port and the second argument must be host:hostport. IPv6 addresses can be specified by enclosing addresses in squarebrackets or by using an alternative syntax: [
/]port and host/hostport. Multiple forwardings may be specified, and additional forwardings can be given on the commandline. Only the superuser can forward privileged ports. By default, the local port is bound in accordance with the GatewayPorts setting. However, anexplicit bind_address may be used to bind the connection to a specific address. The bind_address of 'localhost' indicates that the listeningport be bound for local use only, while an empty address or '*' indicates that the port should be available from all interfaces.

Gives the verbosity level that is used when logging messages from ssh(1). The possible values are: QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2,and DEBUG3. The default is INFO. DEBUG and DEBUG1 are equivalent. DEBUG2 and DEBUG3 each specify higher levels of verbose output.

MACs' Specifies the MAC (message authentication code) algorithms in order of preference. The MAC algorithm is used in protocol version 2 for dataintegrity protection. Multiple algorithms must be comma-separated. The default is:

hmac-md5,hmac-sha1,[email protected],

This option can be used if the home directory is shared across machines. In this case localhost will refer to a different machine on each of the machinesand the user will get many warnings about changed host keys. However, this option disables host authentication for localhost. The argument to this keyword mustbe 'yes' or 'no'. The default is to check the host key for localhost.

Specifies the number of password prompts before giving up. The argument to this keyword must be an integer. The default is 3.

Specifies whether to use password authentication. The argument to this keyword must be 'yes' or 'no'. The default is 'yes'.

Allow local command execution via the LocalCommand option or using the !command escape sequence in ssh(1). The argument must be 'yes' or'no'. The default is 'no'.

Port' Specifies the port number to connect on the remote host. The default is 22.

Specifies the order in which the client should try protocol 2 authentication methods. This allows a client to prefer one method (e.g.keyboard-interactive) over another method (e.g. password) The default for this option is: '
gssapi-with-mic, hostbased, publickey, keyboard-interactive, password'.

Specifies the protocol versions ssh(1) should support in order of preference. The possible values are '1' and '2'. Multiple versions must be comma-separated.The default is '2,1'. This means that ssh tries version 2 and falls back to version 1 if version 2 is not available.

Specifies the command to use to connect to the server. The command string extends to the end of the line, and is executed with the user's shell. In the commandstring, '%h' will be substituted by the host name to connect and '%p' by the port. The command can be basically anything, and should read from its standardinput and write to its standard output. It should eventually connect an sshd(8) server running on some machine, or execute sshd -i somewhere. Host keymanagement will be done using the HostName of the host being connected (defaulting to the name typed by the user). Setting the command to 'none' disablesthis option entirely. Note that CheckHostIP is not available for connects with a proxy command.

This directive is useful in conjunction with nc(1) and its proxy support. For example, the following directive would connect via an HTTP proxy at

ProxyCommand /usr/bin/nc -X connect -x %h %p

Specifies whether to try public key authentication. The argument to this keyword must be 'yes' or 'no'. The default is 'yes'. This option applies toprotocol version 2 only.

Specifies the maximum amount of data that may be transmitted before the session key is renegotiated. The argument is the number of bytes, with an optionalsuffix of 'K', 'M', or 'G' to indicate Kilobytes, Megabytes, or Gigabytes, respectively. The default is between '1G' and '4G', depending on the cipher. Thisoption applies to protocol version 2 only.

Specifies that a TCP port on the remote machine be forwarded over the secure channel to the specified host and port from the local machine. The first argumentmust be [
:]port and the second argument must be host:hostport. IPv6 addresses can be specified by enclosing addresses in squarebrackets or by using an alternative syntax: [
/]port and host/hostport. Multiple forwardings may be specified, and additional forwardings can be given on the commandline. Privileged ports can be forwarded only when logging in as root on the remote machine.

If the port argument is '0', the listen port will be dynamically allocated on the server and reported to the client at run time.

If the bind_address is not specified, the default is to only bind to loopback addresses. If the bind_address is '*' or an empty string, thenthe forwarding is requested to listen on all interfaces. Specifying a remote bind_address will only succeed if the server's GatewayPorts optionis enabled (see sshd_config(5)).

Specifies whether to try rhosts based authentication with RSA host authentication. The argument must be 'yes' or 'no'. The default is 'no'. This optionapplies to protocol version 1 only and requires ssh(1) to be setuid root.

Specifies whether to try RSA authentication. The argument to this keyword must be 'yes' or 'no'. RSA authentication will only be attempted if the identityfile exists, or an authentication agent is running. The default is 'yes'. Note that this option applies to protocol version 1 only.

Specifies what variables from the local environ(7) should be sent to the server. Note that environment passing is only supported for protocol 2. The servermust also support it, and the server must be configured to accept these environment variables. Refer to AcceptEnv in sshd_config(5) for how to configurethe server. Variables are specified by name, which may contain wildcard characters. Multiple environment variables may be separated by whitespace or spreadacross multiple SendEnv directives. The default is not to send any environment variables.

See PATTERNS for more information on patterns.

Sets the number of server alive messages (see below) which may be sent without ssh(1) receiving any messages back from the server. If this threshold is reachedwhile server alive messages are being sent, ssh will disconnect from the server, terminating the session. It is important to note that the use of server alivemessages is very different from TCPKeepAlive (below). The server alive messages are sent through the encrypted channel and therefore will not bespoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The server alive mechanism is valuable when the client or server depend onknowing when a connection has become inactive.

The default value is 3. If, for example, ServerAliveInterval (see below) is set to 15 and ServerAliveCountMax is left at the default, if theserver becomes unresponsive, ssh will disconnect after approximately 45 seconds. This option applies to protocol version 2 only.

Sets a timeout interval in seconds after which if no data has been received from the server, ssh(1) will send a message through the encrypted channel torequest a response from the server. The default is 0, indicating that these messages will not be sent to the server. This option applies to protocol version 2only.

Specifies which smartcard device to use. The argument to this keyword is the device ssh(1) should use to communicate with a smartcard used for storing theuser's private RSA key. By default, no device is specified and smartcard support is not activated.

If this flag is set to 'yes', ssh(1) will never automatically add host keys to the ~/.ssh/known_hosts file, and refuses to connect to hosts whose hostkey has changed. This provides maximum protection against trojan horse attacks, though it can be annoying when the /etc/ssh/ssh_known_hosts file ispoorly maintained or when connections to new hosts are frequently made. This option forces the user to manually add all new hosts. If this flag is set to'no', ssh will automatically add new host keys to the user known hosts files. If this flag is set to 'ask', new host keys will be added to the user knownhost files only after the user has confirmed that is what they really want to do, and ssh will refuse to connect to hosts whose host key has changed. The hostkeys of known hosts will be verified automatically in all cases. The argument must be 'yes', 'no', or 'ask'. The default is 'ask'.

Specifies whether the system should send TCP keepalive messages to the other side. If they are sent, death of the connection or crash of one of the machineswill be properly noticed. However, this means that connections will die if the route is down temporarily, and some people find it annoying.

The default is 'yes' (to send TCP keepalive messages), and the client will notice if the network goes down or the remote host dies. This is important inscripts, and many users want it too.

To disable TCP keepalive messages, the value should be set to 'no'.

Request tun(4) device forwarding between the client and the server. The argument must be 'yes', 'point-to-point' (layer 3), 'ethernet' (layer 2), or'no'. Specifying 'yes' requests the default tunnel mode, which is 'point-to-point'. The default is 'no'.

Specifies the tun(4) devices to open on the client (local_tun) and the server (remote_tun).

The argument must be local_tun[:remote_tun]. The devices may be specified by numerical ID or the keyword 'any', which uses the nextavailable tunnel device. If remote_tun is not specified, it defaults to 'any'. The default is 'any:any'.

Specifies whether to use a privileged port for outgoing connections. The argument must be 'yes' or 'no'. The default is 'no'. If set to 'yes', ssh(1)must be setuid root. Note that this option must be set to 'yes' for RhostsRSAAuthentication with older servers.

User' Specifies the user to log in as. This can be useful when a different user name is used on different machines. This saves the trouble of havingto remember to give the user name on the command line.

Specifies a file to use for the user host key database instead of ~/.ssh/known_hosts.

Specifies whether to verify the remote key using DNS and SSHFP resource records. If this option is set to 'yes', the client will implicitly trust keys thatmatch a secure fingerprint from DNS. Insecure fingerprints will be handled as if this option was set to 'ask'. If this option is set to 'ask', informationon fingerprint match will be displayed, but the user will still need to confirm new host keys according to the StrictHostKeyChecking option. Theargument must be 'yes', 'no', or 'ask'. The default is 'no'. Note that this option applies to protocol version 2 only.

See also VERIFYING HOST KEYS in ssh(1).

If this flag is set to 'yes', an ASCII art representation of the remote host key fingerprint is printed in addition to the hex fingerprint string at loginand for unknown host keys. If this flag is set to 'no', no fingerprint strings are printed at login and only the hex fingerprint string will be printed forunknown host keys. The default is 'no'.

Open Ssh Config File

Specifies the full pathname of the xauth(1) program. The default is /usr/bin/xauth.


A pattern consists of zero or more non-whitespace characters, '*' (a wildcard that matches zero or more characters), or '?' (a wildcard that matchesexactly one character). For example, to specify a set of declarations for any host in the '' set of domains, the following pattern could beused:

Host 192.168.0.?

A pattern-list is a comma-separated list of patterns. Patterns within pattern-lists may be negated by preceding them with an exclamation mark ('!').For example, to allow a key to be used from anywhere within an organisation except from the 'dialup' pool, the following entry (in authorized_keys) could beused:


This is the per-user configuration file. The format of this file is described above. This file is used by the SSH client. Because of the potential forabuse, this file must have strict permissions: read/write for the user, and not accessible by others.

Systemwide configuration file. This file provides defaults for those values that are not specified in the user's configuration file, and for those users who donot have a configuration file. This file must be world-readable.

See Also



OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt andDug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0.

BSD April 14, 2013 BSD

Referenced By


The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container with a running SSH server and take full advantage of VS Code's feature set. Once connected to a server, you can interact with files and folders anywhere on the remote filesystem.

No source code needs to be on your local machine to gain these benefits since the extension runs commands and other extensions directly on the remote machine.

This lets VS Code provide a local-quality development experience — including full IntelliSense (completions), code navigation, and debugging — regardless of where your code is hosted.

Getting started

Note: After reviewing this topic, you can get started with the introductory SSH tutorial.

System requirements

Local: A supported OpenSSH compatible SSH client must also be installed.

Remote SSH host: A running SSH server on:

  • x86_64 Debian 8+, Ubuntu 16.04+, CentOS / RHEL 7+.
  • ARMv7l (AArch32) Raspbian Stretch/9+ (32-bit).
  • ARMv8l (AArch64) Ubuntu 18.04+ (64-bit).
  • Windows 10 / Server 2016/2019 (1803+) using the official OpenSSH Server.
  • macOS 10.14+ (Mojave) SSH hosts with Remote Login enabled.

Other glibc based Linux distributions for x86_64, ARMv7l (AArch32), and ARMv8l (AArch64) should work if they have the needed prerequisites. See the Remote Development with Linux article for information prerequisites and tips for getting community supported distributions up and running.

While ARMv7l (AArch32) and ARMv8l (AArch64) support is available, some extensions installed on these devices may not work due to the use of x86 native code in the extension.


To get started, you need to:

  1. Install an OpenSSH compatible SSH client if one is not already present.

  2. Install Visual Studio Code or Visual Studio Code Insiders.

  3. Install the Remote Development extension pack.

SSH host setup

  1. If you do not have an SSH host set up, follow the directions for Linux, Windows 10 / Server (1803+), or macOS SSH host or create a VM on Azure.

  2. [Optional] If your Linux or macOS SSH host will be accessed by multiple users at the same time, consider enabling Remote.SSH: Remote Server Listen On Socket in VS Code User settings for improved security.

    In the Settings editor:

    See the Tips and Tricks article for details.

  3. [Optional] While password-based authentication is supported, we recommend setting up key based authentication for your host. See the Tips and Tricks article for details.

Connect to a remote host

To connect to a remote host for the first time, follow these steps:

  1. Verify you can connect to the SSH host by running the following command from a terminal / PowerShell window replacing [email protected] as appropriate.

  2. In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1) and use the same [email protected] as in step 1.

  3. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.

    Once you select a platform, it will be stored in VS Code settings under the remote.SSH.remotePlatform property so you can change it at any time.

  4. After a moment, VS Code will connect to the SSH server and set itself up. VS Code will keep you up-to-date using a progress notification and you can see a detailed log in the Remote - SSH output channel.

    Tip: Connection hanging or failing? See troubleshooting tips for information on resolving common problems.

    If you see errors about SSH file permissions, see the section on Fixing SSH file permission errors.

  5. After you are connected, you'll be in an empty window. You can always refer to the Status bar to see which host you are connected to.

    Clicking on the Status bar item will provide a list of remote commands while you are connected.

  6. You can then open any folder or workspace on the remote machine using File > Open... or File > Open Workspace... just as you would locally!

From here, install any extensions you want to use when connected to the host and start editing!

Note: On ARMv7l / ARMv8l glibc SSH hosts, some extensions may not work due to x86 compiled native code inside the extension.

Disconnect from a remote host

To close the connection when you finish editing files on the remote host, choose File > Close Remote Connection to disconnect from the host. The default configuration does not include a keyboard shortcut for this command. You can also simply exit VS Code to close the remote connection.

Remember hosts and advanced settings

If you have a set of hosts you use frequently or you need to connect to a host using some additional options, you can add them to a local file that follows the SSH config file format.

To make setup easy, the extension can guide you through adding a host without having to hand edit this file.

Start by selecting Remote-SSH: Add New SSH Host... from the Command Palette (F1) or clicking on the Add New icon in the SSH Remote Explorer in the Activity Bar.

You'll then be asked to enter the SSH connection information. You can either enter a host name:

Or the full ssh command you would use to connect to the host from the command line:

Finally, you'll be asked to pick a config file to use. You can also set the 'remote.SSH.configFile' property in your User settings.json file if you want to use a different config file than those listed. The extension takes care of the rest!

For example, entering ssh -i ~/.ssh/id_rsa-remote-ssh [email protected] in the input box would generate this entry:

See Tips and Tricks for details on generating the key shown here. You can manually edit this file with anything the SSH config file format supports, so this is just one example.

From this point forward, the host will appear in the list of hosts when you select Remote-SSH: Connect to Host... from the Command Palette (F1) or in the SSH Targets section of the Remote Explorer.

The Remote Explorer allows you to both open a new empty window on the remote host or directly open a folder you previously opened. Expand the host and click on the Open Folder icon next to the folder you want to open on the host.

Managing extensions

VS Code runs extensions in one of two places: locally on the UI / client side, or remotely on the SSH host. While extensions that affect the VS Code UI, like themes and snippets, are installed locally, most extensions will reside on the SSH host. This ensures you have smooth experience and allows you to install any needed extensions for a given workspace on an SSH host from your local machine. This way, you can pick up exactly where you left off, from a different machine complete with your extensions.

If you install an extension from the Extensions view, it will automatically be installed in the correct location. Once installed, you can tell where an extension is installed based on the category grouping.

There will be a category for your remote SSH host:

And also a Local - Installed category:

Note: If you are an extension author and find that your extension is not working properly or installs in the wrong place, see Supporting Remote Development for details.

Local extensions that actually need to run remotely will appear dimmed and disabled in the Local - Installed category. Select Install to install an extension on your remote host.

You can also install all locally installed extensions on the SSH host by going to the Extensions view and selecting Install Local Extensions in SSH: [Hostname] using the cloud button at the right of the Local - Installed title bar. This will display a dropdown where you can select which locally installed extensions to install on your SSH host.

'Always installed' extensions

If there are extensions that you would like to always have installed on any SSH host, you can specify which ones using the remote.SSH.defaultExtensions property in settings.json. For example, if you wanted to install the GitLens and Resource Monitor extensions, specify their extension IDs as follows:

Advanced: Forcing an extension to run locally / remotely

Extensions are typically designed and tested to either run locally or remotely, not both. However, if an extension supports it, you can force it to run in a particular location in your settings.json file.

For example, the setting below will force the Docker extension to run locally and Debugger for Chrome extension to run remotely instead of their defaults:

A value of 'ui' instead of 'workspace' will force the extension to run on the local UI/client side instead. Typically, this should only be used for testing unless otherwise noted in the extension's documentation since it can break extensions. See the article on Supporting Remote Development for details.

Forwarding a port / creating SSH tunnel

Sometimes when developing, you may need to access a port on a remote machine that is not publicly exposed. There are two ways to do this using an SSH tunnel that 'forwards' the desired remote port to your local machine.

Temporarily forwarding a port

Once you are connected to a host, if you want to temporarily forward a new port for the duration of the session, select Forward a Port from the Command Palette (F1) or click on the Forward New Port icon in the Remote Explorer after selecting it from the Activity Bar.

You'll be asked to enter the port you would like to forward and you can give it a name.

A notification will tell you the localhost port you should use to access the remote port. For example, if you forwarded an HTTP server listening on port 3000, the notification may tell you that it was mapped to port 4123 on localhost since 3000 was already in use. You can then connect to this remote HTTP server using http://localhost:4123.

This same information is available in the Forwarded Ports section of the Remote Explorer if you need to access it later.

If you would like VS Code to remember any ports you have forwarded, check Remote: Restore Forwarded Ports in the Settings editor (⌘, (Windows, Linux Ctrl+,)) or set 'remote.restoreForwardedPorts': true in settings.json.

Change local port on tunnel

If you would like the local port of the tunnel to be different than the remote server's, you can change this via the Forwarded Ports panel.

Right-click the tunnel you want to modify, and select Change Local Port in the context menu.

Always forwarding a port

If you have ports that you always want to forward, you can use the LocalForward directive in the same SSH config file you use to remember hosts and advanced settings.

For example, if you wanted to forward ports 3000 and 27017, you could update the file as follows:

Opening a terminal on a remote host

Opening a terminal on the remote host from VS Code is simple. Once connected, any terminal window you open in VS Code (Terminal > New Terminal) will automatically run on the remote host rather than locally.

You can also use the code command line from this same terminal window to perform a number of operations such as opening a new file or folder on the remote host. Type code --help to see all the options available from the command line.

Debugging on the SSH host

Once you are connected to a remote host, you can use VS Code's debugger in the same way you would when running the application locally. For example, if you select a launch configuration in launch.json and start debugging (F5), the application will start on remote host and attach the debugger to it.

See the debugging documentation for details on configuring VS Code's debugging features in .vscode/launch.json.

SSH host-specific settings

VS Code's local User settings are also reused when you are connected to an SSH host. While this keeps your user experience consistent, you may want to vary some of these settings between your local machine and each host. Fortunately, once you have connected to a host, you can also set host-specific settings by running the Preferences: Open Remote Settings command from the Command Palette (F1) or by selecting on the Remote tab in the Settings editor. These will override any User settings you have in place whenever you connect to the host. And Workspace settings will override Remote and User settings.

Working with local tools

The Remote - SSH extension does not provide direct support for sync'ing source code or using local tools with content on a remote host. However, there are two ways to do this using common tools that will work with most Linux hosts. Specifically, you can:

  1. Mount the remote filesystem using SSHFS.
  2. Sync files to/from the remote host to your local machine using rsync.

SSHFS is the most convenient option and does not require any file sync'ing. However, performance will be significantly slower than working through VS Code, so it is best used for single file edits and uploading/downloading content. If you need to use an application that bulk reads/write to many files at once (like a local source control tool), rsync is a better choice.

Known limitations

Remote - SSH limitations

  • Using key based authentication is strongly recommended. Passwords and other tokens entered for alternate authentication methods are not saved.
  • Alpine Linux and non-glibc based Linux SSH hosts are not supported.
  • Older (community supported) Linux distributions require workarounds to install the needed prerequisites.
  • PuTTY is not supported on Windows.
  • If you clone a Git repository using SSH and your SSH key has a passphrase, VS Code's pull and sync features may hang when running remotely. Either use an SSH key without a passphrase, clone using HTTPS, or run git push from the command line to work around the issue.
  • Local proxy settings are not reused on the remote host, which can prevent extensions from working unless the appropriate proxy information is configured on the remote host (for example global HTTP_PROXY or HTTPS_PROXY environment variables with the appropriate proxy information).
  • See here for a list of active issues related to SSH.

Docker Extension limitations

While the Docker extension can run both remotely and locally, if it is already installed locally, you will be unable to install on a remote SSH host without first uninstalling it locally. We will address this problem in a future VS Code release.

Open Ssh Config File

Extension limitations

Many extensions will work on remote SSH hosts without modification. However, in some cases, certain features may require changes. If you run into an extension issue, there is a summary of common problems and solutions that you can mention to the extension author when reporting the issue.

In addition, some extensions installed on ARMv7l (AArch322) / ARMv8l (AArch64) devices may not work due to native modules or runtimes in the extension that only support x86_64. In these cases, the extensions would need to opt-in to supporting these platforms by compiling / including binaries for ARMv7l / ARMv8l.

Common questions

How do I set up an SSH client on ...?

See Installing a supported SSH client for details.

How do I set up an SSH server on ...?

See Installing a supported SSH server for details on setting up an SSH server for your host.

Can I sign in to my SSH server with another/additional authentication mechanism like a password?

Yes, you should be prompted to enter your token or password automatically. However, passwords are not saved, so using key based authentication is typically more convenient.

How do I fix SSH errors about 'bad permissions'?

See Fixing SSH file permission errors for details on resolving these types of errors.


What Linux packages / libraries need to be installed on remote SSH hosts?

Most Linux distributions will not require additional dependency installation steps. For SSH, Linux hosts need to have Bash (/bin/bash), tar, and either curl or wget installed and those utilities could be missing from certain stripped down distributions. Remote Development also requires kernel >= 3.10, glibc >=2.17, libstdc++ >= 3.4.18. Only glibc-based distributions are supported currently, so by extension Alpine Linux is not supported.

See Linux Prerequisites for details.

What are the connectivity requirements for the VS Code Server when it is running on a remote machine / VM?

Installation of VS Code Server requires that your local machine has outbound HTTPS (port 443) connectivity to:

  • * (Azure CDN)

By default, the Remote - SSH will attempt to download on the remote host, but if you enable remote.SSH.allowLocalServerDownload, the extension will fall back to downloading VS Code Server locally and transferring it remotely once a connection is established.

You can install extensions manually without an internet connection using the Extensions: Install from VSIX... command, but if you use the extension panel to install extensions, your local machine and VS Code Server server will need outbound HTTPS (port 443) access to:

  • * (Azure CDN)
  • * (Azure CDN)

Finally, some extensions (like C#) download secondary dependencies from or Others (like Visual Studio Live Share) may have additional connectivity requirements. Consult the extension's documentation for details if you run into trouble.

All other communication between the server and the VS Code client is accomplished through the authenticated, secure SSH tunnel.

Can I use local tools on source code sitting on the remote SSH host?

Yes. Typically this is done using SSHFS or by using rsync to get a copy of the files on your local machine. SSHFS mounts the remote filesystem is ideal for scenarios where you need to edit individual files or browse the source tree and requires no sync step to use. However, it is not ideal for using something like a source control tool that bulk manages files. In this case, the rsync approach is better since you get a complete copy of the remote source code on your local machine. See Tips and Tricks for details.

Can I use VS Code when I only have SFTP/FTP filesystem access to my remote host (no shell access)?

Some cloud platforms only provide remote filesystem access for developers rather than direct shell access. VS Code Remote Development was not designed with this use case in mind since it negates the performance and user experience benefits.

However, this use case can typically be handled by combining extensions like SFTP with remote debugging features for Node.js, Python, C#, or others.

As an extension author, what do I need to do?

The VS Code extension API abstracts away local/remote details so most extensions will work without modification. However, given extensions can use any node module or runtime they want, there are situations where adjustments may need to be made. We recommend you test your extension to be sure that no updates are required. See Supporting Remote Development for details.

Questions or feedback

  • See Tips and Tricks or the FAQ.
  • Search on Stack Overflow.
  • Add a feature request or report a problem.
  • Contribute to our documentation or VS Code itself.
  • See our CONTRIBUTING guide for details.