Build and use the Linux development environment-SSH and ssh

Source: Internet
Author: User
Tags ssh server

Build and use the Linux development environment-SSH and ssh

SSH is short for Secure Shell, developed by the Network Working Group of IETF. SSH is a security protocol built on the application layer and transport layer.


SSH is a reliable protocol designed for remote logon sessions and other network services. It is often used for remote logon and copying data between users.


The SSH protocol can effectively prevent information leakage during Remote Management. SSH was originally a program on a UNIX system and then quickly extended to other operating platforms. SSH can compensate for Network Vulnerabilities when used correctly. The SSH client is applicable to multiple platforms. Almost all UNIX platforms-including HP-UX, Linux, AIX, Solaris, Digital UNIX, Irix, and other platforms-can run SSH.


Install related tools

Install the SSH server:

Sudo apt-get install openssh-server


Install the SSH client:

Sudo apt-get install openssh-client


Relationship between the client and the server: If machine A wants to be remotely controlled by machine B, machine A needs to install the SSH server, and machine B needs to install the SSH client.


If a problem occurs during use, restart the SSH server:

Sudo service ssh restart


Test use

Command: ssh-l username hostip

Ssh: Command

-L: option. It is the letter "L", not the number "1"

Username: username for remote Logon

Hostip: ip address of the remote Logon


View the ip address of the remote Logon:



Remote Login (here is the user wencong (machine A) Remote Login edu (machine B), you do not need to sudo:



SSH informs the user that the host cannot be identified, and then type "yes", SSH will write the relevant information "~ /. Ssh/know_hosts ". If you try again, no such information will be available. After entering the password, you can log on to the host.


Then, the system prompts you to enter the logon password:



Login successful:





To remotely log on to Linux on Windows, install the xmanager package for Windows.

Xmanager is a software package. Including xshell, xftp, xstart and other software.

Xshell: an ssh, TELNET, and RLOGIN terminal software for Windows. It allows users to easily and securely access Unix/Linux Hosts on Windows platforms.

Xftp: it is an FTP and SFTP File Transfer Program Applied to the Windows platform. Xftp securely transfers files between Unix, Linux, and Windows platforms.

Xstart: allows remote access to the server using the graphic interface, but the efficiency is slightly lower. It only supports gnome Desktop.


Here, we use xshell software. For details, see: Linux development environment setup and use-remote connection to ubuntu through xshell.


SSH Configuration

There is no default user configuration file during SSH installation. We can configure it as needed.


In the preceding example, we need to log on to the edu user on 10.221.20.16. Every time we have to press "ssh-l edu 10.221.20.16 ".


The following describes how to simplify this command.

In ~ /. Create the file config in ssh:



Write the following content in config:



Then, Run "ssh edu" on the command line to log on to the edu user on 10.221.20.16:



Note: If the first line of config is changed to Host * test, the command is changed to ssh test. The name "test" can be customized as needed.




Of course, there are more options, such as ForwardAgent, Compression, ForwardX11 FallBackToRsh, which will not be listed here.


Use scp to copy files and directories

SSH provides commands and shells to log on to the remote server. By default, users are not allowed to copy files, but a "scp" command is provided. The usage is as follows:


Copy local files to remote:
Scp FileName RemoteUserName @ RemoteHostIp: RemoteFile
Scp FileName RemoteHostIp: RemoteFolder
Scp FileName RemoteHostIp: RemoteFile

Copy local directory to remote:
Scp-r FolderName RemoteUserName @ RemoteHostIp: RemoteFolder
Scp-r FolderName RemoteHostIp: RemoteFolder

Copy a remote file to a local device:
Scp RemoteUserName @ RemoteHostIp: RemoteFile FileName
Scp RemoteHostIp: RemoteFolder FileName
Scp RemoteHostIp: RemoteFile FileName

Remote directory copy to local:
Scp-r RemoteUserName @ RemoteHostIp: RemoteFolder FolderName
Scp-r RemoteHostIp: RemoteFolder FolderName


Only one command is tested here, and other operations are similar.

Copy a remote file to a local device:

Scp RemoteUserName @ RemoteHostIp: RemoteFile FileName

RemoteUserName: Remote User Name

RemoteHostIp: remote ip

RemoteFile: Remote file with a path

FileName: The name after the copy to the local directory. It can be taken with a path, without a path, and copied to the current directory.


View remote directories and files:



View local directories and files:



Copy remote files:




To copy a remote file, you can modify its name at will:



You can specify the storage path for copying remote files:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.