// Tutorial //

How To Use SSH to Connect to a Remote Server

Published on September 10, 2013 · Updated on January 18, 2022
English
How To Use SSH to Connect to a Remote Server

Introduction

Core Syntax

Microsoft’s documentation to add OpenSSH to PowerShell. If you would rather have a full Linux environment available, you can set up WSL , the Windows Subsystem for Linux, which will include ssh by default. Finally, as a lightweight third option, you can install Git for Windows , which provides a native Windows bash terminal environment that includes the ssh command. Each of these are well-supported and whichever you decide to use will come down to preference.

If you are using a Mac or Linux, you will already have the ssh command available in your terminal.

The most straightforward form of the command is:

  1. ssh remote_host

    The remote_host in this example is the IP address or domain name that you are trying to connect to.

    This command assumes that your username on the remote system is the same as your username on your local system.

    If your username is different on the remote system, you can specify it by using this syntax:

    1. ssh remote_username@remote_host

      Once you have connected to the server, you may be asked to verify your identity by providing a password. Later, we will cover how to generate keys to use instead of passwords.

      To exit the ssh session and return back into your local shell session, type:

      How Does SSH Work?

      1. How To Configure SSH

            1. How To Log Into SSH with Keys

              How Does Key-based Authentication Work?

              How To Create SSH Keys

                  1. How To Transfer Your Public Key to the Server

                    1. Client-Side Options

                          1. Disabling Password Authentication

                              1. Conclusion

                                working with SFTP to perform command line file transfers.

We’ve made it super easy to add SSH Keys to your new or existing DigitalOcean virtual machines.

Learn more here


About the authors

Still looking for an answer?

Ask a question Search for more help

Was this helpful?
10 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Hi Justin!

Greetings from Argentina!

Awesome article about SSH Server configuration file.

As in your own words: “ The host keys declarations specify where to look for global host keys. We will discuss what a host key is later.

Did you discuss about host keys in other Digital Ocean article?

Have a wonderful day!

fernando

can we use write command to a user who is connect to us using ssh connection?

On cPanel based server you can connect it easily.

Follow this video: https://www.youtube.com/watch?v=9Yx1gZKgb5Y

DrBeauWebber March 7, 2017

Hi, Thanks, extremely clear guidance. The local system is Cygwin on a WIndows 7 PC, The remote system is Ubuntu.

I still have a problem : “we sent a publickey packet” - but there is no reply :

debug1: SSH2_MSG_SERVICE_REQUEST sent debug2: service_accept: ssh-userauth debug1: SSH2_MSG_SERVICE_ACCEPT received debug2: key: /home/jbww/.ssh/id_rsa (0x80061bd0), debug2: key: /home/jbww/.ssh/id_dsa (0x0), debug2: key: /home/jbww/.ssh/id_ecdsa (0x0), debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/jbww/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Authentications that can continue: publickey,password debug1: Trying private key: /home/jbww/.ssh/id_dsa debug1: Trying private key: /home/jbww/.ssh/id_ecdsa debug2: we did not send a packet, disable method debug1: Next authentication method: password

Does anyone have an idea as to what I can try ?

Hey thanks. It’s very helpful tutorial.

I have query regarding to see the server console for the running processes. So, can you please suggest me the command to see the running server console, so that i will be able to see the errors if occurs?

Hey thanks. It’s the clearest tutorial I found! and your blog looks nice.

I guess you forgot to mention you can disable password authentication after setting up SSH keys, as not to be exposed to brute force attacks.

  • Is SSH server included in every Ubuntu desktop machine? how should we enable it? Maybe you’ve written an article before, I’ll search for it.
  • Does Ubuntu desktop provides a GUI interface in order to use -X option?

    my login isn’t working for the console… any tips?

    Andrew SB
    DigitalOcean Employee
    DigitalOcean Employee badge
    May 19, 2014

    @forgotmyorange : If you connect with <code>ssh -vv root @your .ip.address</code> it will add debugging output so that you can see what is happening behind the scenes. If it is actually connecting with the key, you should see something like:

    debug1: Authentications that can continue: publickey,password debug1: Next authentication method: publickey debug1: Offering RSA public key: /home/asb/.ssh/id_rsa debug2: we sent a publickey packet, wait for reply debug1: Server accepts key: pkalg ssh-rsa blen 279