This page is about the OpenSSH Practically every Unix and Linux system includes the SSH Command in Linux Other SSH Commands Using the Linux client Specifying a different user name Executing remote commands on the server SSH client configuration file Configuring public key authentication Configuring port forwarding SSH command line options A little history The There are other SSH commands besides the client ssh-keygen - creates a key pair for public key authentication ssh-copy-id - configures a public key as authorized on a server ssh-agent - agent to hold private key for single sign-on ssh-add - tool to add a key to the agent scp - file transfer client with RCP-like command interface sftp - file transfer client with FTP-like command interface sshd - OpenSSH server Linux typically uses the OpenSSH client. The ssh command to log into a remote machine is very simple. To log in to a remote computer called sample.ssh.com, type the following command at a shell prompt: If this is the first time you use ssh to connect to this remote machine, you will see a message like: Type Each server has a host key, and the above question related to verifying and saving the host key, so that next time you connect to the server, it can verify that it actually is the same server. Once the server connection has been established, the user is authenticated. Typically, it asks for a password. For some servers, you may be required to type in a one-time password generated by a special hardware token. Once authentication has been accepted, you will be at the shell prompt for the remote machine. It is also possible to use a different username at the remote machine by entering the command as: The above can also be expressed with the syntax: The ssh command is often also used to remotely execute commands on the remote machine without logging in to a shell prompt. The syntax for this is: For example, to execute the command: on host sample.ssh.com, type the following command at a shell prompt: After authenticating to the remote server, the contents of the remote directory will be displayed, and you will return to your local shell prompt. -x Disables X11 forwarding. The To configure passwordless public key authentication, you may want to create an SSH key and set up an authorized_keys file. See the pages on ssh-keygen and ssh-copy-id for more information. Command-line options can be used to set up port forwarding. Local fowarding means that a local port (at the client computer) is tunneled to an IP address and port from the server. Remote forwarding means that a remote port (at the server computer) is forwarded to a given IP address and port from the client machine. See the page on configuring port forwarding on how to configure them. OpenSSH also supports forwarding Unix domain sockets and IP packets from a tunnel device to establish a VPN (Virtual Private Network). Some of the most important command-line options for the OpenSSH client are: -1 Use protocol version 1 only. -2 Use protocol version 2 only. -4 Use IPv4 addresses only. -6 Use IPv6 addresses only. -A Enable forwarding of the authentication agent connection. -a Disable forwarding of the authentication agent connection. -C Use data compression -c cipher_spec Selects the cipher specification for encrypting the session. -D -E log_file Append debug logs to log_file instead of standard error. -F configfile Specifies a per-user configuration file. The default for the per-user configuration file is ~/.ssh/config. -g Allows remote hosts to connect to local forwarded ports. -i identity_file A file from which the identity key (private key) for public key authentication is read. -J -l login_name Specifies the user to log in as on the remote machine. -p port Port to connect to on the remote host. -q Quiet mode. -V Display the version number. -v Verbose mode. -X Enables X11 forwarding. SSH replaced several older commands and protocols in Unix and Linux the 1990s. The include telnet, rlogin, and rsh. SSH runs at TCP/IP port 22. This is right between ftp and telnet, which are 20 years older. Read the story of how SSH got port 22. The following video summarizes how and why SSH was originally developed.ssh
command on Unix/Linux or the Mac terminal. For general information about SSH and other implementations, see the SSH protocol home page.ssh
command. This command is used to start the SSH client program that enables secure connection to the SSH server on a remote machine. The ssh
command is used from logging into the remote machine, transferring files between the two machines, and for executing commands on the remote machine.Contents
SSH Command in Linux
ssh
command provides a secure encrypted connection between two hosts over an insecure network. This connection can also be used for terminal access, file transfers, and for tunneling other applications. Graphical X11 applications can also be run securely over SSH from a remote location.Other SSH Commands
ssh
. Each has its own page.Using the Linux client
ssh sample.ssh.com
The authenticity of host 'sample.ssh.com' cannot be established.
DSA key fingerprint is 04:48:30:31:b0:f3:5a:9b:01:9d:b3:a7:38:e2:b1:0c.
Are you sure you want to continue connecting (yes/no)?
yes
to continue. This will add the server to your list of known hosts (~/.ssh/known_hosts
) as seen in the following message:Warning: Permanently added 'sample.ssh.com' (DSA) to the list of known hosts.
Specifying a different user name
ssh alternative-username@sample.ssh.com
ssh -l alternative-username sample.ssh.com
Executing remote commands on the server
ssh hostname command
ls /tmp/doc
ssh sample.ssh.com ls /tmp/doc
SSH client configuration file
ssh
command reads its configuration from the SSH client configuration file ~/.ssh/config
. For more information, see the page on SSH client configuration file.Configuring public key authentication
Configuring port forwarding
SSH command line options
[bind_address:]
port Dynamic application-level port forwarding. This allocates a socket to listen to port on the local side. When a connection is made to this port, the connection is forwarded over the secure channel, and the application protocol is then used to determine where to connect to from the remote machine.[user@]
host[:port]
Connect to the target host by first making a ssh connection to the pjump host[(/iam/jump-host) and then establishing a TCP forwarding to the ultimate destination from there.A little history
FAQs
What is the use of SSH command in Linux? ›
SSH Command in Linux
The ssh command provides a secure encrypted connection between two hosts over an insecure network. This connection can also be used for terminal access, file transfers, and for tunneling other applications. Graphical X11 applications can also be run securely over SSH from a remote location.
The SSH protocol creates a secure connection between two remote machines. An SSH config file helps easily configure the default values for these connections and enables efficient streamlining of SSH connections.
What is option in SSH command? ›SSH Option | Description |
---|---|
-V | Displays the version of ssh tool and exits. |
-v | Prints debugging messages for ssh connection. The verbose mode is useful when troubleshooting configuration issues. |
-X | Use this option to enable X11 forwarding. |
-x | Disable X11 forwarding. |
You can start an SSH session in your command prompt by executing ssh user@machine and you will be prompted to enter your password. You can create a Windows Terminal profile that does this on startup by adding the commandline setting to a profile in your settings.json file inside the list of profile objects.
How to control Linux with SSH? ›- Go to Connection -> SSH -> Tunnels.
- Type in the source port number in the Source port field.
- Type the VNC server address and port in the Destination field.
- Start the SSH session as you normally would.
- Connect to your server with a VNC client of your choice.
- Open the SSH configuration file /etc/ssh/sshd_config.
- Disable non-admin SSH tunneling. ...
- Disable agent forwarding (which is enabled by default). ...
- Update authentication methods. ...
- If SSH is not going to be used for other purposes on your system, consider restricting use to an explicit list of allowed HSTS users.
The ssh program on a host receives its configuration from either the command line or from configuration files ~/.ssh/config and /etc/ssh/ssh_config .
How to create SSH configuration? ›- In the Settings dialog ( Ctrl Alt 0S ) , go to Tools | SSH Configurations.
- In the left-hand pane that lists all the existing SSH configurations, click .
- Use the Visible only for this project checkbox to enable reuse of this server access configuration in other projects.
A command-line option or simply option (also known as a flag or switch) modifies the operation of a command; the effect is determined by the command's program. Options follow the command name on the command line, separated by spaces.
How do you use options in UNIX? ›Most UNIX utilities require you to prefix options with a hyphen. However, this requirement is specific to the utility and not the shell. If you need to use several options, you can usually (but not always) group them into one argument that starts with a single hyphen; do not put spaces between the options.
What is option in UNIX command? ›
Linux/UNIX commands have options and/or arguments that can be typed after the basic command to further specify an action. Arguments are typically paths to files (ref. File Systems) and options assign more specific functions to the command, or add additional actions to the command.
How to check SSH status in Linux? ›You can verify that the SSH server is running by running “ssh localhost” on the Linux side. If it asks for the key/password, the server is active: If the server is not running, you can manually start it by running “sudo service sshd start” or “sudo systemctl start sshd”.
How to check SSH connection in Linux? ›The ss Command
Another useful utility to find SSH connections is the ss command. It's a tool that's used to investigate sockets. Something to consider when using ss is that we don't see the usernames behind the connections as we do with netstat.
Copy and install the public ssh key using ssh-copy-id command on a Linux or Unix server. Add yourself to sudo or wheel group admin account. Disable the password login for root account. Test your password less ssh keys login using ssh user@server-name command.
What is benefit of using SSH? ›The main advantage of SSH is the use of encryption to ensure the secure transfer of information between the client and the server. SSH allows users to execute shell commands on a remote computer in the same way as if they were sitting in front of the physical computer.
Why is SSH key used? ›An SSH key is an access credential for the SSH (secure shell) network protocol. This authenticated and encrypted secure network protocol is used for remote communication between machines on an unsecured open network. SSH is used for remote file transfer, network management, and remote operating system access.
Why is SSH protocol used? ›The SSH protocol (also referred to as Secure Shell) is a method for secure remote login from one computer to another. It provides several alternative options for strong authentication, and it protects communications security and integrity with strong encryption.