How to Use SSH

If you are 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. At the same time, SSH needs to be enabled at both ends of the connection. Follow the instructions below to ensure your connection is secure.

Connecting for the first time

How to Use SSH Picture 1How to Use SSH Picture 1

Install SSH. With Windows, you need to download and install the SSH client program. 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 choice.

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 were 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.

How to Use SSH Picture 2How to Use SSH Picture 2

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.

How to Use SSH Picture 3How to Use SSH Picture 3

Checking connection. Before starting to create security keys and transfer files, you should check to make sure that SSH is configured correctly on the computer you are using as well as the other connection. Please enter the following command instead with your username on the other computer and by the address of that server or computer:

$ ssh @

Once the connection is established, you will be asked to enter a password. As you type, the mouse pointer will not move and any characters entered will not be displayed.

If there is an error in this step, SSH has been misconfigured on your computer or the computer on the other end does not accept SSH connections.

Learn basic commands

How to Use SSH Picture 4How to Use SSH Picture 4

Navigate the SSH shell (command interpreter). During the first connection to the other computer, you should 'locate' to the HOME folder. To move within the directory structure, use the command cd:

cd .Move to the folder right in front of the directory tree

cd Move to any specific folder.

cd /home/tên_thư_mục/đường_dẫn/Move to a specific folder from the root folder (home).

cd ~return to your HOME directory.

How to Use SSH Picture 5How to Use SSH Picture 5

Check the content contained in the current directory. To view files and folders in the current directory, you can use the command ls:

lslists every directory and file in the current directory.

ls –llists the contents of the folder along with additional information such as size, permissions, and date.

ls-aLists all contents, including hidden files and folders.

How to Use SSH Picture 6How to Use SSH Picture 6

Copy files from your location to the other computer. To copy files from the computer you are using to the computer you are accessing remotely, you can use the command scp:

scp /thư_mục_cục_bộ/ví_dụ_1.txt @ :<đường_dẫn> will copy example1.txt to a specific on the computer being accessed remotely. You can leave the field blank to copy to the root directory of this computer.

scp @ :/home/ví_dụ_1.txt ./ will move example1.txt from the home directory on the remote computer to the directory you are entering directly on this head machine.

How to Use SSH Picture 7How to Use SSH Picture 7

Copy files through shell. You can use the command cpto copy files in the same directory or to a predetermined directory:

cp ví_dụ_1.txt ví_dụ_2.txtwill create a copy of example1.txt and name it example2.txt right in the current directory.

cp ví_dụ_1.txt thư_mục/will create a copy of example1 in the directory specified by directory.

How to Use SSH Picture 8How to Use SSH Picture 8

Transfer and rename files. If you want to rename or move (without copying) certain files, you can use the command mv:

mv ví_dụ_1.txt ví_dụ_2.txtwill rename example_1.txt to example_2.txt, the file is still in the old directory.

mv thư_mục_1 thư_mục_2rename folder_1 to folder_2. The content contained in the folder remains unchanged.

mv ví_dụ_1.txt thư_mục_1/move example1.txt to folder1.

mv ví_dụ_1.txt thư_mục_1/ví_dụ_2.txtMove example1.txt to folder1 and rename it to example2.txt.

How to Use SSH Picture 9How to Use SSH Picture 9

Delete files and folders. To delete content on a computer being accessed remotely, you can use the command rm:

rm ví_dụ_1.txt delete the file named example_1.txt.

rm –I ví_dụ_1.txt Delete file example1.txt after receiving confirmation from you.

rm thư_mục_1/delete folder_1 with all its contents.

How to Use SSH Picture 10How to Use SSH Picture 10

Change permissions of files. You can change the read and write permissions of a file with the command chmod:

chmod u+w ví_dụ_1.txtadd permission to write (modify) files to user (u). You can also use plugins gfor group permissions and ofor world permissions.

chmod g+r ví_dụ_1.txtAdd permission to read (access) files to the group.

The list of commands you can use to secure or unlock various aspects of your device is quite long.

How to Use SSH Picture 11How to Use SSH Picture 11

Learn other miscellaneous basic commands. There are still a few more important commands that are used quite a lot on the shell interface, including:

mkdir thư_mục_mớicreate a subfolder called new_folder.

pwddisplays the current directory location.

whoDisplays who is logging into the system.

pico newfile.txtor vi newfile.txtcreate a new file and open a file editor. Different machines may have different file editors installed. Pico and vi are the two most popular programs. In case your computer uses another file editor, you may have to use other commands.

How to Use SSH Picture 12How to Use SSH Picture 12

Get detailed information about any command. If you're not sure what a command does, you can use it manto learn about all the parameters and possible uses:

man displays information about that command

man –k finds all command pages for the specified keyword.

Generate encrypted keys

How to Use SSH Picture 13How to Use SSH Picture 13

Generate your SSH key. These keys allow you to connect to a remote device without having to enter a password each time you connect. This method is much safer because with it, you do not need to send a password over the network.

Create a locked folder 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 not required. If you don't want to create a password, just press Enter. Two keys id_rsa and id_rsa.pub will be created in the .ssh directory.

Change private key permissions. To ensure that only you can read the private key, enter the command$ chmod 600 .ssh/id_rsa

How to Use SSH Picture 14How to Use SSH Picture 14

Leave the public key on the other computer. Once you've created the key, you're ready to place the public key on the other end of the connection so you can connect without a password. Enter the following command, replacing the necessary parts as shown:

$ scp .ssh/id_rsa.pub @ :

Don't forget the colon (:) at the end of the command.

You will be asked to enter your password before starting the file transfer.

How to Use SSH Picture 15How to Use SSH Picture 15

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 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 already exist, it will be initialized:$ cat id_rsa.pub >> .ssh/authorized_keys

Change the permissions for the SSH directory to allow access:$ chmod 700 .ssh

How to Use SSH Picture 16How to Use SSH Picture 16

Check if the connection is working or not. After installing the lock on the computer at the other end of the connection, you should be able to create a connection without having to enter a password. Use the following command to check your connection:$ ssh @

If you don't have to enter a password when connecting, the lock must have been configured correctly.

5 ★ | 2 Vote