Linux remote login

General use Linux as a server, and the server is generally placed in the room, you can not operate your Linux server room.

Then we need to log in to a remote Linux servers to manage and maintain the system.

Linux system is through ssh remote login service implementation, the default ssh service port number is 22.

Window System on Linux Telnet client has SecureCRT, Putty, SSH Secure Shell, etc. In this paper, for example Putty to login to the remote server.

putty Download: http: //www.putty.org/

If you downloaded the putty, the following pop-up window and then double-click putty.exe.

5_1

In the box, enter the following Host Name (or IP address) you want to log on the remote server IP (server ip can be viewed via the ifconfig command), and then press Enter.

5_12

At this point, we are prompted to enter the login user name.

5_13

Enter the root then enter, re-enter the password, you can log in to the remote linux system.

5_14


Authentication mechanism using the key remote login linux

SSH is the abbreviation of the Secure Shell, developed by the IETF Network Working Group (Network Working Group).

SSH is a secure protocol at the application layer and the transport layer basis.

First, use the tool PUTTYGEN.EXE generate the key pair. After opening tool PUTTYGEN.EXE shown below:

5_15

The tool can generate key three formats: SSH-1 (RSA) SSH-2 (RSA) SSH-2 (DSA), we use the default format i.e. SSH-2 (RSA). Number of bits in a generated key is the size of the generated key, and the larger this value, the more complex the key generation, the higher the security. Here we write 2048.

5_16

Then click Generate begin to generate the key pair:

5_17

Note that the mouse to move back and forth in the process, otherwise the progress bar will not move.

5_18

到这里,密钥对已经生成了。你可以给你的密钥输入一个密码,(在Key Passphrase那里)也可以留空。然后点 Save public key 保存公钥,点 Save private Key 保存私钥。笔者建议你放到一个比较安全的地方,一来防止别人偷窥,二来防止误删除。接下来就该到远程linux主机上设置了。

1)创建目录 /root/.ssh 并设置权限

[root@localhost ~]# mkdir /root/.ssh mkdir 命令用来创建目录,以后会详细介绍,暂时只了解即可。

[root@localhost ~]# chmod 700 /root/.ssh chmod 命令是用来修改文件属性权限的,以后会详细介绍。

2)创建文件 / root/.ssh/authorized_keys

[root@localhost ~]# vim /root/.ssh/authorized_keys vim 命令是编辑一个文本文件的命令,同样在后续章节详细介绍。

3)打开刚才生成的public key 文件,建议使用写字板打开,这样看着舒服一些,复制从AAAA开头至 "---- END SSH2 PUBLIC KEY ----" 该行上的所有内容,粘贴到/root/.ssh/authorized_keys 文件中,要保证所有字符在一行。(可以先把复制的内容拷贝至记事本,然后编辑成一行载粘贴到该文件中)。

在这里要简单介绍一下,如何粘贴,用vim打开那个文件后,该文件不存在,所以vim会自动创建。按一下字母"i"然后同时按shift + Insert 进行粘贴(或者单击鼠标右键即可),前提是已经复制到剪切板中了。粘贴好后,然后把光标移动到该行最前面输入 ssh-rsa ,然后按空格。再按ESC,然后输入冒号wq 即 :wq 就保存了。格式如下图:

5_19

4) then set putty options, SSh point on the left side of the window -> Auth, click Browse to select the right side of the window ... just generated private key, and then point to Open, this time enter the root, do not type a password to log in.

5_20

If you set up in front of the Key Passphrase, then the time will prompt you to enter a password. For more security suggest that you set up a Key Passphrase.

Guess you like

Origin www.cnblogs.com/gp678/p/11710137.html