Linux common servers build SSH and SCP

Source: Internet
Author: User
Tags ssh access ssh server

1.SSH1.1SSH Introduction

SSH (Secure Shell), developed by network Working group of the IETF, is a security protocol based on the application layer and transport layer.

SSH is a protocol that provides security for Telnet sessions and other network services, and is commonly used for remote logins and copies of data between users.

SSH has a strong cross-platform capability

The use of SSH service needs to install the necessary server and client, if a machine wants to be remote from the B machine, then a machine needs to install the SSH server, B machine needs to install the SSH client

1.2 Installing the ssh1.2.1 installation SSH server

[Email protected]:~$ sudo apt-get install Openssh-server
[sudo] python password:
Reading Package List ... Complete
Analyzing Dependency tree for Package
Reading status information ... Complete
Openssh-server is already the latest version (1:7.2p2-4ubuntu2.4).
The following packages are installed automatically and are not needed now:
linux-headers-4.4.0-121 Linux-headers-4.4.0-121-generic linux-headers-4.4.0-22
Linux-headers-4.4.0-22-generic Linux-image-4.4.0-121-generic Linux-image-4.4.0-22-generic
Linux-image-extra-4.4.0-121-generic Linux-image-extra-4.4.0-22-generic
Use ' sudo apt autoremove ' to uninstall it (them).
0 packages were upgraded, 0 new packages were installed, 0 packages were uninstalled, 377 packages were not upgraded.

1.2.2 Telnet to the SSH server

SSH [email protected]

macdemacbook-pro:~ mac$ ssh [email protected]
[email protected] ' s password:
Permission denied, please try again.
[email protected] ' s password:
Welcome to Ubuntu 16.04.1 LTS (gnu/linux 4.4.0-31-generic x86_64)

  • Documentation:https://help.ubuntu.com
  • Management:https://landscape.canonical.com
  • Support:https://ubuntu.com/advantage

381 packages can be updated.
3 updates are security updates.

Need to restart the system
Last login:wed June 6 02:08:42 2018 from 192.168.1.5
[Email protected]:~$ pwd
/home/python

    • In the process of using SSH access, if there is an access error, you can see if there is a file ~/.ssh/known_ssh exists, if there is a delete to resolve. 2.scp
    • Remote Copy file, scp-r2.1 installation Openssh-server
    • The prerequisite for using this command is to require that the target host is already installed Openssh-server

      [Email protected]:~$ sudo apt-get install Openssh-server
      [sudo] python password:
      Reading Package List ... Complete
      Analyzing Dependency tree for Package
      Reading status information ... Complete
      Openssh-server is already the latest version (1:7.2p2-4ubuntu2.4).
      The following packages are installed automatically and are not needed now:
      linux-headers-4.4.0-121 linux-headers-4.4.0-121-generic linux-headers-4.4.0-22 Linux-headers-4.4.0-22-generic
      Linux-image-4.4.0-121-generic Linux-image-4.4.0-22-generic Linux-image-extra-4.4.0-121-generic
      Linux-image-extra-4.4.0-22-generic
      Use ' sudo apt autoremove ' to uninstall it (them).
      0 packages were upgraded, 0 new packages were installed, 0 packages were uninstalled, 377 packages were not upgraded.
      [Email protected]:~$

2.2. Use the format
  • Scp-r target username @ Destination Host IP address:/destination file absolute path/absolute/relative path saved to native 2.2.1 Copy files on server to local

  • Copy files can not add-r, copy folder must be added
  • A terminal on a Mac connects to the target host's SCP server
  • Copying remote files to a locally specified directory

    macdemacbook-pro:~ mac$ ls
    Desktop Movies ipmsg.db
    Documents Music Baidu Cloud synchronization disk
    Downloads Pictures
    Library Public
    #拷贝远程文件到本地指定目录
    macdemacbook-pro:~ mac$ scp-r [email protected]:/home/python/desktop/1.py./desktop
    [email protected] ' s password:
    1.py
    100% 1030 1.0kb/s 00:00

  • To see if replication succeeded

    macdemacbook-pro:~ mac$ CD desktop/
    Macdemacbook-pro:desktop mac$ ls
    1.py python test.py
    Macdemacbook-pro:desktop mac$

  • Copy remote file to local directory and modify file name directly

    macdemacbook-pro:~ mac$ scp-r [email protected]:/home/python/desktop/1.py./desktop/2.py
    [email protected] ' s password:
    1.py 100% 1030 1.0kb/s 00:00
    macdemacbook-pro:~ mac$ CD desktop/
    Macdemacbook-pro:desktop mac$ ls
    1.py 2.py python test.py

  • Direct copy to local current directory you can write the local file name you want to store
    Picture description

2.2.2 Copy Local files to remote

Acdemacbook-pro:desktop mac$ SCP 2.py [email protected]:/home/python/desktop/11.py
[email protected] ' s password:
2.py 100% 1030 1.0kb/s 00:00
Macdemacbook-pro:desktop mac$

View

[Email protected]:~/desktop$ ls
11.py 1.py 1.sh AAA ABC Desktop Test Test.txt

3.2.2.3 Local directory replication to remote

2.2.4 Remote directory replication to Local

Linux common servers build SSH and SCP

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.