SSH into a remote server

Mark Shust
InstructorMark Shust
Share this video with your friends

Social Share Links

Send Tweet
Published 5 years ago
Updated 3 years ago

Learn the basics of how to SSH into a remote server. Find out how to specify a specific port with the -p flag, or a different SSH to use for a connection with the -i flag. You can also run one-off bash commands without dropping into a bash shell prompt.

Instructor: [00:00] To SSH into a remote host we will use the SSH command. When using the SSH command followed by just the IP address or host name the command will assume the same user name of your host machine for authentication. That's usually not what is desired.

[00:17] To use a specific user name prefix the remote host name with the desired user name followed by an @ symbol. This is the standard way to SSH into a remote host. Most times this is all that is needed to authenticate. Sometimes SSH servers will block connections on the default port 22 for security reasons and bind the SSH server to a different port.

[00:40] Let's assume the SSH server is bound to port 2022 instead of port 22. We add a -p flag followed by our port number 2022. Another command flag that is important is the -I flag. The I stands for identity and allows us to specify a different SSH key to authenticate with. This makes it possible to set up any number of different SSH keys to connect to any number of different hosts.

[01:10] SSHing into a remote host drops you right into a bash shell, but you may just want to run one command and immediately exit. Instead of dropping a newer bash shell you may specify a command to run after typing in your connection string. This allows you to run one-off commands, a quick bash script, or anything else you wish without needing to create and stay within an SSH session.

egghead
egghead
~ 27 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today