Shell Programming SSH Remote Connection

Source: Internet
Author: User
Tags scp file

1,ssh Understanding

There are two servers, one is local, one is the cloud, all Linux systems, if we want to access the cloud system locally, then we can use SSH command, can be used to log in locally remote connection, upload or download files to the remote server.

Preparation of SSH connections:

1, the remote server has a public IP, there is a port, there is a user and know the password (root user can also line)

2, the computer to open the SSHD service, the default is open.

2, command

Logon remote server format: SSH user name @IP address-P Port number # If the connection is successful, you will be prompted for the password. Is the password of the user on the remote server

3,SCP File Upload and download

Upload the local file to the remote server:

Scp-p port number local file path user name @ Remote server address: remote path

The files on the remote server are downloaded locally:

Scp-p Port number User name @ Remote server address: Remote path local file path    

Note that if you upload or download a folder and the files under it, you can specify the-r parameter.

4, expand SSH free-secret link remote server

Core idea:

1. The local host generates the public key, the private key is stored on its own, and the public key is passed to the remote host. SSH folder under Authorized_keys file (default is this, append, Authorized_keys permissions if 600)

2. Local connection to the remote host, the public key pair can be exempt from the secret login.

Steps

1. Generate the public and private key files on the local host Id_rsa and id_rsa.pub (triple-tap to enter).

  1. [[email protected] ~]# ssh-keygen-t RSA
  2. Generating public/private RSA key pair.
  3. Enter file in which to save the key (/ROOT/.SSH/ID_RSA):
  4. Enter passphrase (empty for no passphrase):
  5. Enter same Passphrase again:
  6. Your identification has been saved In/root/.ssh/id_rsa.
  7. Your public Key has been saved in/root/.ssh/id_rsa.pub.
  8. The key fingerprint is :
  9. 67:da:0d:79:e0:d6:2b:cd:7d:22:af:51:7e:9c:75:fe [email protected]
  10. The key ' s randomart image is :
  11. +--[RSA 2048]----+
  12. | |
  13. | |
  14. | . |
  15. | . + |
  16. | S B O. o|
  17. | * * = o+|
  18. | . o B +.=|
  19. | . + +.|
  20. | ... e|
  21. +-----------------+ 

2. Create the ~/.SSH directory on the remote host with a permission of 700 and append the ~/.ssh/id_rsa.pub locally to the ~/.ssh/authorized_keys on the remote host

The whole process is a bit like a cookie.

Shell Programming SSH Remote Connection

Related Article

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.