Linux command: SSH SCP ssh-keygen-t RSA usage

Source: Internet
Author: User


SSH Remote connection command:

Usage format:ssh ipaddr does not specify the user to log on to the remote host as the user of the current host login system

ssh [email protected] telnet to a host as a user via SSH protocol

usage:ssh [email protected] Telnet to the 192.168.1.100 host via the SSH protocol as root

ssh-l USERNAME ipaddr equivalent to ssh [email protected] login mode

SSH [email protected] ' commond ' to username the user to execute Commond command on the remote host.

SCP Remote replication command:

usage Format: SCP src original file or directory dest target directory same as CP command

-R: Directory is also copied

-A: Hidden files, linked files are copied together

SCP [email protected]:/path/to/somefile/path/to/local from the remote host to the local host to

scp/path/to/local [email protected]:/path/to/somefile from the local host to the remote host


SSH-KEYGEN-T RSA Generate key

The generated key is saved in the following path

Private key key saved to: ~/.ssh/id_rsa Current Build user's home directory

Public key saved to: ~/.ssh/id_rsa.pub

-f/path/to/key_file specifying password save path and file name

-P ' password ': Specifies the password for the encrypted private key


The public key is appended to the remote host in the ~/.ssh/authorized_keys file or ~/.ssh/authorized_keys2 file in the user's home directory, and is generally appended to the Authorized_keys file.


Ssh-copy-id: Transfer the public key to the remote server ~/.ssh/id_rsa.pub public key save location

Ssh-copy-id This command is not supported by all Linux versions

-I ~/.ssh/id_rsa.pub [email protected]

Usage:ssh-copy-id-i ~/.ssh/id_rsa.pub [email protected]


Example: How to realize Telnet to the host via SSH does not need to enter password authentication

Method One: Append the generated public key to the home directory corresponding to the remote server

~/.ssh/authorized_keys file.


[[email protected] ~]# ssh-keygen-t RSA generate key

Generating public/private RSA key pair.

Enter file in which to save the key (/ROOT/.SSH/ID_RSA):

/root/.ssh/id_rsa already exists.

Overwrite (y/n)? Y

Enter passphrase (empty for no passphrase):

Enter same Passphrase again:

Your identification have been saved in /root/.ssh/id_rsa. Private key Path

Your public key had been saved in /root/.ssh/id_rsa.pub. Public Key Path

The key fingerprint is:

c6:30:84:08:94:ff:91:58:82:56:25:d4:4b:53:98:e3 [email protected]

[Email protected] ~]# Ls/root/.ssh/id_rsa

/root/.ssh/id_rsa

[Email protected] ~]# ls/root/.ssh/id_rsa.pub

/root/.ssh/id_rsa.pub

[Email protected] ~]# scp/root/.ssh/id_rsa.pub [email protected]:/root first copy the locally generated public key to the remote In the home directory of the host

[[email protected] ~]# ssh [email protected] first telnet to the host

[[email protected] ~]# ls

Id_rsa.pub Install.log Install.log.syslog

[[email protected] ~]# mkdir. SSH remote host No. SSH directory requires a new directory, and the directory permission must be 700

[Email protected] ~]# chmod. ssh/Change permission to 700

[[email protected] ~]#cat ~/id_rsa.pub >> ~/.ssh/authorized_keys Append save

[[Email protected] ~] #exit after exiting the remote host after SSH login and can not need to enter a password to login


method Two: Sir into the key, and then through the command directly copied to the remote host


[[email protected] ~]# ssh-keygen-t RSA generate key

Generating public/private RSA key pair.

Enter file in which to save the key (/ROOT/.SSH/ID_RSA):

/root/.ssh/id_rsa already exists.

Overwrite (y/n)? Y

Enter passphrase (empty for no passphrase):

Enter same Passphrase again:

Your identification have been saved in /root/.ssh/id_rsa. Private key Path

Your public key had been saved in /root/.ssh/id_rsa.pub. Public Key Path

The key fingerprint is:

c6:30:84:08:94:ff:91:58:82:56:25:d4:4b:53:98:e3 [email protected]

[Email protected] ~]# Ls/root/.ssh/id_rsa

/root/.ssh/id_rsa

[Email protected] ~]# ls/root/.ssh/id_rsa.pub

/root/.ssh/id_rsa.pub

[Email protected] ~]# ssh-copy-id-i/root/.ssh/id_rsd.pub [email protected]

[[email protected] ~]# ssh [email protected] re-login to the remote host via SSH without entering a password







This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1884297

Linux command: SSH SCP ssh-keygen-t RSA usage

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.