SSH for remote login and usage tips

Source: Internet
Author: User

    • About SSH

SSH is the abbreviation for secure Shell, developed by the IETF Network Working Group, and SSH is a security protocol based on the application layer and transport layer.

SSH is currently a more reliable protocol that provides security for Telnet sessions and other network services. Often used for remote logins, and for copying data between users.

The use of SSH protocol can effectively prevent the information leakage in the remote management process. SSH was originally a program on a UNIX system, and later expanded quickly to other operating platforms. SSH can compensate for vulnerabilities in the network when it is used correctly. The SSH client is available on a variety of platforms. Almost all UNIX platforms-including HP-UX, Linux, AIX, Solaris, Digital UNIX, Irix, and other platforms-can run SSH.

For the SSH Protocol section, refer to the following blog

http://blog.csdn.net/macrossdzh/article/details/5691924

    • SSH installation

    • View SSH version information

SSH client installed by default on Ubuntu 14.04 LTS

You can use the command

Dpkg-l | grep ssh-client

View related client Information

Use

Ssh-v

You can view the version of SSH

Installing the SSH server

sudo apt-get install Openssh-server

SSH service is turned on by default when installation is complete

Restart Service

sudo service ssh restart

Test using

Ssh-l username HostIP

*username: User name that is logged in remotely

*hostip: Remotely logged-on IP

Log in to the remote host

SSH [email protected]

    • Tips for simplifying commands

Method One

Configuring SSH

Create a file config in the ~/.ssh directory

Touch ~/.ssh/config

Write in config file

Host *testhostname 192.168.1.102User Doggy

* Replace the test part with your own content

Use commands after configuration is complete

SSH test

You can implement the user doggy on the login 192.168.1.102.

The test here can be replaced with any name

Method Two

Add HostIP to/etc/hosts, using the following format

HostIP Name

Name: Alias for IP

You can now use the command

SSH [email protected]

Log in to the remote host

Doggy: My remote host user name

But it's still very troublesome, and then simplifying

Create a file Doggy_ssh (name pickup) in ~/bin and add the following

SSH [email protected]

Save exit, add executable permission

sudo chmode +x doggy_ssh

You can now log in to the remote host using DOGGY_SSH directly at the terminal (this is much better)

The problem comes, each time when using SSH login is always to enter the password, use the following methods to avoid

Generate SSH Key

Ssh-keygen

And then all the way to the return, using the SSH default, this time a public key is generated in the ~/.SSH, and a private key, which is what we need

Create the file Authorized_keysin the ~/.SSH directory on the server side of SSH and add the public key you just generated to the file

This allows you to log on to the remote host without entering the password

Another way to add a public key to an SSH server, using a command

Ssh-copy-id-i ~/.ssh/id_rsa.pub HostIP

Using SCP to implement file and directory copy, in fact SCP use is the same as the use of CP, but when using SCP, to add the remote host IP, the following is the detailed

SSH provides a number of commands and shells used to log on to the remote server. By default, users are not allowed to copy files, but an "SCP" command is provided, using the following method:

Local files are copied to remote:

SCP filename [email protected]:remotefilescp filename REMOTEHOSTIP:REMOTEFOLDERSCP filename remotehostip:remotefile

Local directory replication to remote:

Scp-r FolderName [email protected]:remotefolderscp-r FolderName Remotehostip:remotefolder

Remote file copy to Local:

SCP [email protected]:remotefile filenamescp remotehostip:remotefolder FILENAMESCP remotehostip:remotefile FileName

Remote directory replication to Local:

scp-r [email protected]:remotefolder foldernamescp-r Remotehostip:remotefolder FolderName

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

Remote file copy to Local:

SCP [Email Protected]:remotefile FileName

Remoteusername: Remote User name

Remotehostip: Remote IP

RemoteFile: Remote file, can take path

FileName: Copy to local name, can take path, copy to current directory without path


Ps: This article refers to the following blog:

Use Ssh-keygen and Ssh-copy-id three steps to implement SSH login without password

Linux under SSH installation configuration use detailed:

Http://www.linuxidc.com/Linux/2015-03/115056.htm

If you are having difficulty in using, you can refer to the video about Happypeter

Http://haoduoshipin.com/v/62

The video is not long, but the person thinks it is very clear.

SSH for remote login and usage tips

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.