In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article introduces the relevant knowledge of "how to connect the SSH of Linux system". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Linux system SSH (Secure Shell Protocol) service
One: what is a SSH service?
Before data transfer, SSH encrypts the data that needs to be transferred to ensure the security of the session and the security of the data transferred in the session. The SSH client also includes a remote copy command scp
Second: the structure of SSH
SSH service consists of server software (openssh) and client (SSH, SecureCRT, Xshell). SSH uses port 22 by default. It has two incompatible versions 1.x and 2.x (1.x is not secure). The SSH server is a daemon that listens for client requests all the time in the background. Sshd is the process name of the SSH server.
Three: SSH authentication type
1. Security verification based on password
That is, it is usually said to connect through the account, password, and server IP address.
[root@Centos] # ssh-p22 root@192.168.1.3
The authenticity of host '192.168.1.3 (192.168.1.3)' can't be established.
RSA key fingerprint is 86:41:46:5c:d9:e0:98:a5:15:ee:b4:01:a5:37:49:c4.
Are you sure you want to continue connecting (yes/no)? Yes
Warning: Permanently added '192.168.1.3' (RSA) to the list of known hosts.
Root@192.168.1.3's password:
Last login: Sat Aug 27 15:34:13 2016 from 192.168.1.2
[root@localhost ~] # ifconfig eth0
Eth0 Link encap:Ethernet HWaddr 00:0C:29:53:55:79
Inet addr:192.168.1.3 Bcast:192.168.1.255 Mask:255.255.255.0
Inet6 addr: fe80::20c:29ff:fe53:5579/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:109 errors:0 dropped:0 overruns:0 frame:0
TX packets:82 errors:0 dropped:0 overruns:0 carrier:0
Collisions:0 txqueuelen:1000
RX bytes:11967 (11.6 KiB) TX bytes:8771 (8.5 KiB)
The first connection will prompt you whether you need to continue the connection, but not the second connection, because added '192.168.1.3' (RSA) to the list of known hosts. The password has been written to this file
[root@Centos] # cat ~ / .ssh/known_hosts
192.168.1.3 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2RkUy6sZGRTFtKI1ANZTGkwgLQuXHDh8MqR4TB9WE4rEpUxpGzz2Slm9jK0ezeaooiqo7s4e9n2Sm5WYRZGNyeZELA9hqBfBWa9VEwnyQlr3KM/R03G0rGxjjIhicZ9s1jO69myOHpCJfflpFuILUgsPcSmCOvbs7s8/0Rqz6rrVs9QZqn5X/cF++8ejC3a5ZUrIdDmTHJOo03Og7utGthGxZQht5IR0IAH3ibmf00Q2VvFAAV7BzcB/nFeNmfe+KzEAFTOL+Ak66EIvbyYVDDS9gI9ifUk7nmGHmV1PJ9vUov+zRPUKCqLNlL2kalan1StHQJtI2awo1FElhhaZGQ==
2. Security verification based on key
A pair of key pairs is established in advance, then the public key is placed on the server side, and the private key is placed on the client side of SSH. Finally, the data is encrypted and transmitted by this way of key verification.
IV: startup of SSH service
First, we check to see if the SSH service is installed
[root@Centos ~] # rpm-qa | grep-Ei "openssh"
Openssh-askpass-5.3p1-94.el6.x86_64
Openssh-clients-5.3p1-94.el6.x86_64
Openssh-5.3p1-94.el6.x86_64
Openssh-server-5.3p1-94.el6.x86_64
Check to see if the service starts
[root@Centos ~] # / etc/init.d/sshd status
Openssh-daemon (pid 1629) is running...
View the ports used by the SSH service
[root@Centos ~] # netstat-lntup | grep ssh
Tcp 0 0 0.0.0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0
Tcp 0 0: 22:: * LISTEN 1629/sshd
Given the port number, you can check which service is used.
[root@Centos] # lsof-I tcp:22
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
Sshd 1629 root 3U IPv4 14002 0t0 TCP *: ssh (LISTEN)
Sshd 1629 root 4U IPv6 14010 0t0 TCP *: ssh (LISTEN)
Sshd 1999 root 3r IPv4 15990 0t0 TCP 192.168.1.2 IPv4 SSH-> 192.168.1.200 IPv4 50176 (ESTABLISHED)
Five: SSH connection
Ssh-p port user @ server IP address
[root@Centos] # ssh-p22 root@192.168.1.3
Root@192.168.1.3's password:
Last login: Sun Aug 28 11:47:44 2016 from 192.168.1.2
[root@localhost ~] # cd / tmp
[root@localhost tmp] # touch 123.txt
[root@localhost tmp] # ls
123.txt pulse-Z24bYtSaCQMb yum.log
Go to the remote host to check if this file is generated
Last login: Sun Aug 28 12:03:30 2016 from 192.168.1.2
[root@localhost ~] # ls / tmp
123.txt pulse-Z24bYtSaCQMb yum.log
Ssh-p port user @ server IP address COMD
If you just log in to the remote host to view some configurations, you can use the above command
[root@Centos] # ssh-p22 root@192.168.1.3 free-m
Root@192.168.1.3's password:
Total used free shared buffers cached
Mem: 980 181 798 0 13 56
-/ + buffers/cache: 111869
Swap: 1983 0 1983
Six: commands attached to SSH
1. Scp remote copy command
[root@Centos ~] # man scp
SCP (1) BSD General Commands Manual
NAME scp-secure copy (remote file copy program)
-P port
-p keep attributes
-r copy directory
[root@Centos tmp] # ls
Crontab.cBNvTM text.log virtual-root.flvVsv tar.gz.20160820
[root@Centos tmp] # scp-P22 tar.gz.20160820 root@192.168.1.3:/tmp/
Root@192.168.1.3's password:
Tar.gz.20160820 100% 577 0.6KB/s 00:00
The remote host tests whether the copy is successful
[root@localhost ~] # cd / tmp
[root@localhost tmp] # ls
123.txt pulse-Z24bYtSaCQMb tar.gz.20160820 yum.log
Successfully copied
2. FTP function service sftp
Command format
Use: sftp-oPort=xx user @ remote host IP
[root@Centos tmp] # sftp-oport=22 root@192.168.1.3
Connecting to 192.168.1.3...
Root@192.168.1.3's password:
Sftp > put / tmp/tardir/ / tmp
Skipping non-regular file / tmp/tardir/
The client checks whether the upload is successful.
[root@localhost ~] # cd / tmp
[root@localhost tmp] # ls
123.txt pulse-Z24bYtSaCQMb tar.gz.20160820 yum.log
Sftp > get / tmp/tar.gz.20160820 / opt/
Fetching / tmp/tar.gz.20160820 to / opt/tar.gz.20160820
/ tmp/tar.gz.20160820 100% 577 0.6KB/s 00:00
Sftp > ^ D
[root@Centos ~] # cd / opt
[root@Centos opt] # ls
P rh tar.gz.20160820
Download files from the remote host to the local host
This is the end of the content of "how to connect Linux system SSH". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.