DEV Community

mich0w0h
mich0w0h

Posted on

SSH: Connect to a server with a port number and a username

Every time I try to SSH I forget how to do it.

That's why I decided to take notes with this post.

What I want to achieve

  • connect a server on a certain port using SSH.
  • username and password are given.

Ask man

Just run the command in the terminal.

$ man ssh
Enter fullscreen mode Exit fullscreen mode

The output is here;

NAME
     ssh – OpenSSH remote login client

SYNOPSIS
     ssh [-46AaCfGgKkMNnqsTtVvXxYy] [-B bind_interface] [-b bind_address] [-c cipher_spec] [-D [bind_address:]port] [-E log_file] [-e escape_char]
         [-F configfile] [-I pkcs11] [-i identity_file] [-J destination] [-L address] [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option]
         [-P tag] [-p port] [-Q query_option] [-R address] [-S ctl_path] [-W host:port] [-w local_tun[:remote_tun]] destination
         [command [argument ...]]
Enter fullscreen mode Exit fullscreen mode

This is not enough to specify the username.

To log in with a particular username the command would be this;

$ ssh username@hostname
Enter fullscreen mode Exit fullscreen mode

There it is!

Connect a server using SSH

Input the following command in the terminal.

$ ssh -p port username@hostname
Enter fullscreen mode Exit fullscreen mode

The connection would be established after entering the password as the prompt asks.

References

Heroku

This site is built on Heroku

Join the ranks of developers at Salesforce, Airbase, DEV, and more who deploy their mission critical applications on Heroku. Sign up today and launch your first app!

Get Started

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more