• About
  • Contact
  • Cookie
  • Disclaimer
  • Privacy Policy
  • Change the purpose of use

Tnhelearning.edu.vn - Various useful general information portal

  • Photo
  • Bio
  • How To
  • Tech

How to Use SSH

February 20, 2024 by admin Category: How To

You are viewing the article How to Use SSH  at Tnhelearning.edu.vn you can quickly access the necessary information in the table of contents of the article below.

X

wikiHow is a “wiki” site, which means that many of the articles here are written by multiple authors. To create this article, 20 people, some of whom are anonymous, have edited and improved the article over time.

This article has been viewed 1,768 times.

If you’re connecting to another computer over the network, you probably want to keep your data safe. And SSH is a viable option. To do that, you need to properly set up SSH on your computer and then create an encrypted connection to the server. Also, SSH needs to be enabled on both ends of the connection. Follow the instructions below to secure your connection.

Table of Contents

  • Steps
    • Connecting for the first time
    • Learn Basic Commands
    • Generate encrypted key

Steps

Connecting for the first time

Image titled Use SSH Step 1

Image titled Use SSH Step 1

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/b5/Use-SSH-Step-1-Version-5.jpg/v4-728px-Use-SSH-Step-1- Version-5.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/b/b5/Use-SSH-Step-1-Version-5.jpg/v4-728px-Use- SSH-Step-1-Version-5.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Install SSH. With Windows, you need to download and install the SSH client. The most famous is Cygwin: you can download this program for free from the developer’s website. Download and install as you would any other program. Besides Cygwin, PuTTY is also a popular free option.

  • During the installation of Cygwin, you must choose to install OpenSSH from the Net section.
  • Linux and Mac OS X have SSH available. That’s because SSH is a UNIX system and Linux and OS X are both developed from this system.
  • If you are using Windows 10 with the Anniversary Update, you can install Windows Subsystem for Linux: with this feature, SSH will be pre-installed.
Image titled Use SSH Step 2

Image titled Use SSH Step 2

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/7/7e/Use-SSH-Step-2-Version-5.jpg/v4-728px-Use-SSH-Step-2- Version-5.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/7/7e/Use-SSH-Step-2-Version-5.jpg/v4-728px-Use- SSH-Step-2-Version-5.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Run SSH. Open the terminal program installed by Cygwin, or Bash on Ubuntu on Windows 10, or Terminal on OS X and Linux. SSH uses a terminal interface to interact with other computers. SSH doesn’t have a graphical interface, so you’ll have to get used to typing commands.
Image titled Use SSH Step 3

Image titled Use SSH Step 3

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/41/Use-SSH-Step-3-Version-3.jpg/v4-728px-Use-SSH-Step-3- Version-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/4/41/Use-SSH-Step-3-Version-3.jpg/v4-728px-Use- SSH-Step-3-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Checking connection. Before you begin to generate security keys and transfer files, you should check to make sure that SSH is properly configured on the computer you are using as well as the other end of the connection. Enter the following command, replacing <username> with your username on the other computer and <remote_device> with the address of that server or computer:

  • $ ssh <tên_người_dùng>@<thiết_bị_từ_xa>
  • Once the connection is established, you will be asked to enter a password. As you type, the cursor will not move and any entered characters will not be displayed.
  • If you fail at this step, SSH is either misconfigured on your computer or the computer on the other end is not accepting SSH connections.
READ More:   How to Copy Files to an External Hard Drive

Learn Basic Commands

Image titled Use SSH Step 4

Image titled Use SSH Step 4

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/1/1d/Use-SSH-Step-4-Version-3.jpg/v4-728px-Use-SSH-Step-4- Version-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/1/1d/Use-SSH-Step-4-Version-3.jpg/v4-728px-Use- SSH-Step-4-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Navigate the SSH shell (command interpreter). During the first connection to the other computer, you should “close” in the HOME directory. To navigate through the directory structure, use the cd command: [1] X Research Sources

  • cd .. move to the directory right ahead in the directory tree
  • cd <tên_thư_mục> to which specific directory.
  • cd /home/tên_thư_mục/đường_dẫn/ move to specific directory from the root directory (home).
  • cd ~ return to your HOME directory.
Image titled Use SSH Step 5

Image titled Use SSH Step 5

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/c/ce/Use-SSH-Step-5-Version-2.jpg/v4-728px-Use-SSH-Step-5- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/c/ce/Use-SSH-Step-5-Version-2.jpg/v4-728px-Use- SSH-Step-5-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Check the contents of the current directory. To view files and directories in the current directory, you can use the command ls : [2] X Research Sources

  • ls lists every directory and file in the current directory.
  • ls –l lists the contents of the directory with additional information such as size, permissions, and date.
  • ls-a lists all the contents, including hidden files and folders.
Image titled Use SSH Step 6

Image titled Use SSH Step 6

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/e8/Use-SSH-Step-6-Version-2.jpg/v4-728px-Use-SSH-Step-6- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/e/e8/Use-SSH-Step-6-Version-2.jpg/v4-728px-Use- SSH-Step-6-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Copy files from your place to the other computer. To copy files from the computer you are using to the computer you are accessing remotely, you can use the scp command:

  • scp /thư_mục_cục_bộ/ví_dụ_1.txt <tên_người_dùng>@<thiết_bị_từ_xa>:<đường_dẫn> will copy instance_1.txt to the specific <path> on the computer being accessed remotely. You can leave the <path> field blank to copy to the root directory of this computer.
  • scp <tên_người_dùng>@<thiết_bị_từ_xa>:/home/ví_dụ_1.txt ./ will move instance_1.txt from the home directory on the remote access computer to the directory you are entering directly on this terminal.
Image titled Use SSH Step 7

Image titled Use SSH Step 7

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/51/Use-SSH-Step-7-Version-2.jpg/v4-728px-Use-SSH-Step-7- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/5/51/Use-SSH-Step-7-Version-2.jpg/v4-728px-Use- SSH-Step-7-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Copy files through shell. You can use the cp command to copy files in the same directory or to a specified directory:

  • cp ví_dụ_1.txt ví_dụ_2.txt will make a copy of example_1.txt and name it example_2.txt right in the current directory.
  • cp ví_dụ_1.txt thư_mục/ will create a copy of example_1 in the directory specified by directory.
Image titled Use SSH Step 8

Image titled Use SSH Step 8

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/a/ae/Use-SSH-Step-8-Version-2.jpg/v4-728px-Use-SSH-Step-8- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/a/ae/Use-SSH-Step-8-Version-2.jpg/v4-728px-Use- SSH-Step-8-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Convert and rename files. If you want to rename or move (without copying) certain files, you can use the mv command:

  • mv ví_dụ_1.txt ví_dụ_2.txt will rename example_example_1.txt to example_2.txt, the file is still in the old directory.
  • mv thư_mục_1 thư_mục_2 rename folder_1 to folder_2. The contents of the folder remain unchanged.
  • mv ví_dụ_1.txt thư_mục_1/ move example_1.txt to folder_1.
  • mv ví_dụ_1.txt thư_mục_1/ví_dụ_2.txt move example_1.txt to folder_1 and rename it to example_2.txt.
READ More:   How to get rid of bed bugs the natural way
Image titled Use SSH Step 9

Image titled Use SSH Step 9

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/99/Use-SSH-Step-9-Version-2.jpg/v4-728px-Use-SSH-Step-9- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/99/Use-SSH-Step-9-Version-2.jpg/v4-728px-Use- SSH-Step-9-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Delete files and folders. To delete content on the computer that is being accessed remotely, you can use the rm command:

  • rm ví_dụ_1.txt deletes file named example_1.txt.
  • rm –I ví_dụ_1.txt delete file example_1.txt after getting confirmation from you.
  • rm thư_mục_1/ deletes directory_1 and all its contents.
Image titled Use SSH Step 10

Image titled Use SSH Step 10

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/8b/Use-SSH-Step-10-Version-2.jpg/v4-728px-Use-SSH-Step-10- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/8/8b/Use-SSH-Step-10-Version-2.jpg/v4-728px-Use- SSH-Step-10-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Change permissions of files. You can change the read and write permissions of a file with the chmod command:

  • chmod u+w ví_dụ_1.txt adds write (modify) file permission to user (u). You can also use the g plugin for group permissions and o for world permissions.
  • chmod g+r ví_dụ_1.txt adds file read (access) permission to the group.
  • The list of commands that you can use to secure or open various aspects of your machine is quite long. [3] X Research Sources
Image titled Use SSH Step 11

Image titled Use SSH Step 11

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/9/97/Use-SSH-Step-11-Version-2.jpg/v4-728px-Use-SSH-Step-11- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/9/97/Use-SSH-Step-11-Version-2.jpg/v4-728px-Use- SSH-Step-11-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Learn other mixed basic commands. There are still a few more important commands that are used a lot on the shell interface, including:

  • mkdir thư_mục_mới creates a subdirectory called new_directory.
  • pwd shows the current directory location.
  • who displays who is logged into the system.
  • pico newfile.txt or vi newfile.txt create a new file and open the file editor. Different machines may have different file editors installed. Pico and vi are the two most popular. In case your computer uses a different file editor, you may have to use other commands.
Image titled Use SSH Step 12

Image titled Use SSH Step 12

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/b/be/Use-SSH-Step-12-Version-2.jpg/v4-728px-Use-SSH-Step-12- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/b/be/Use-SSH-Step-12-Version-2.jpg/v4-728px-Use- SSH-Step-12-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Get detailed information about any command. If you’re not sure what a command does, you can use the man command to learn about all the parameters and possible uses:

  • man <lệnh> displays information about that command
  • man –k <từ_khóa> finds all command pages for the specified keyword. [4] X Research Sources

Generate encrypted key

Image titled Use SSH Step 13

Image titled Use SSH Step 13

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/8/83/Use-SSH-Step-13-Version-2.jpg/v4-728px-Use-SSH-Step-13- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/8/83/Use-SSH-Step-13-Version-2.jpg/v4-728px-Use- SSH-Step-13-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Generate your SSH key. These keys allow you to connect to a remote device without having to enter a password every time you connect. This method is much more secure because with it, you do not need to send the password over the network.

  • Create a locked directory on your computer by entering the command $ mkdir .ssh
  • Generate private and public keys using the command $ ssh-keygen –t rsa
  • You will be asked if you want to create a password for the key: it is optional. If you don’t want to create a password, just press Enter. The two keys id_rsa and id_rsa.pub will be generated in the .ssh directory.
  • Change private key permissions. To make sure that only you can read the private key, enter the command $ chmod 600 .ssh/id_rsa
Image titled Use SSH Step 14

READ More:   How to Dye Hair with Coffee

Image titled Use SSH Step 14

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/4/40/Use-SSH-Step-14-Version-2.jpg/v4-728px-Use-SSH-Step-14- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/4/40/Use-SSH-Step-14-Version-2.jpg/v4-728px-Use- SSH-Step-14-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Leave the public key on the other computer. After generating the key, you are ready to place the public key on the other end of the connection so that you can connect without a password. Enter the following command, replacing the necessary parts as shown:

  • $ scp .ssh/id_rsa.pub <tên_người_dùng>@<thiết_bị_từ_xa>:
  • Don’t forget the colon (:) at the end of the command.
  • You will be asked to enter a password before starting the file transfer.
Image titled Use SSH Step 15

Image titled Use SSH Step 15

{“smallUrl”:”https://www.wikihow.com/images_en/thumb/5/50/Use-SSH-Step-15-Version-2.jpg/v4-728px-Use-SSH-Step-15- Version-2.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/5/50/Use-SSH-Step-15-Version-2.jpg/v4-728px-Use- SSH-Step-15-Version-2.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
Install the public key on the other computer. Once set, you need to install the lock on the other machine for it to work properly. First, log in to the other end computer the same way you did in step 3.

  • Create an SSH directory if it doesn’t already exist on this computer: $ mkdir .ssh
  • Mount your key with the licensed key file. If this file does not exist, it will be initialized: $ cat id_rsa.pub >> .ssh/authorized_keys
  • Change SSH directory permissions to allow access: $ chmod 700 .ssh
  • Image titled Use SSH Step 16

    Image titled Use SSH Step 16

    {“smallUrl”:”https://www.wikihow.com/images_en/thumb/e/e5/Use-SSH-Step-16-Version-3.jpg/v4-728px-Use-SSH-Step-16- Version-3.jpg”,”bigUrl”:”https://www.wikihow.com/images/thumb/e/e5/Use-SSH-Step-16-Version-3.jpg/v4-728px-Use- SSH-Step-16-Version-3.jpg”,”smallWidth”:460,”smallHeight”:345,”bigWidth”:728,”bigHeight”:546,”licensing”:”<div class=”mw-parser -output”></div>”}
    Check if the connection is working or not. Once you’ve installed the key on the computer on the other end of the connection, you should be able to make the connection without having to enter a password. Use the following command to check your connection: $ ssh <tên_người_dùng>@<thiết_bị_từ_xa>

    • If you don’t have to enter a password when connecting, the key is configured correctly.
  • X

    wikiHow is a “wiki” site, which means that many of the articles here are written by multiple authors. To create this article, 20 people, some of whom are anonymous, have edited and improved the article over time.

    This article has been viewed 1,768 times.

    If you’re connecting to another computer over the network, you probably want to keep your data safe. And SSH is a viable option. To do that, you need to properly set up SSH on your computer and then create an encrypted connection to the server. Also, SSH needs to be enabled on both ends of the connection. Follow the instructions below to secure your connection.

    Thank you for reading this post How to Use SSH at Tnhelearning.edu.vn You can comment, see more related articles below and hope to help you with interesting information.

    Related Search:

    Related Posts

    How to Create Curved Text in Photoshop
    How to fall asleep faster
    How to Install FBReader to Read eBooks

    Category: How To

    Previous Post: « How to Edit Documents on iPhone
    Next Post: How to Use Vlookup in Excel Spreadsheet »

    Copyright © 2025 · Tnhelearning.edu.vn - Useful Knowledge