标签:pen inet6 lis 格式 city list 图片 shell linu
Linux系统SSH(Secure Shell Protocol)服务在数据传输前,SSH会对需要传输的数据进行加密,保证会话安全与会话中传输数据的安全,SSH客户端还包括一个远程拷贝命令scp
SSH服务由服务端软件(openssh)和客户端(SSH、SecureCRT、Xshell)组成,SSH默认使用22端口,它两个不兼容的版本1.x、2.x(1.x不安全),SSH服务端是一个守护进程,在后台时刻监听客户端的请求,sshd就是SSH服务端的进程名
也就是通常所说的通过账号、密码、与服务端IP地址去连接
[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)
[root@Centos ~]# cat ~/.ssh/known_hosts
192.168.1.3 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2RkUy6sZGRTFtKI1ANZTGkwgLQuXHDh8MqR4TB9WE4rEpUxpGzz2Slm9jK0ezeaooiqo7s4e9n2Sm5WYRZGNyeZELA9hqBfBWa9VEwnyQlr3KM/R03G0rGxjjIhicZ9s1jO69myOHpCJfflpFuILUgsPcSmCOvbs7s8/0Rqz6rrVs9QZqn5X/cF++8ejC3a5ZUrIdDmTHJOo03Og7utGthGxZQht5IR0IAH3ibmf00Q2VvFAAV7BzcB/nFeNmfe+KzEAFTOL+Ak66EIvbyYVDDS9gI9ifUk7nmGHmV1PJ9vUov+zRPUKCqLNlL2kalan1StHQJtI2awo1FElhhaZGQ==
事先建立一对密钥对,然后将公用的密钥放在服务端,把私有密钥放在SSH的客户端,最终通过这种密钥验证方式进行加密传输数据
[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
[root@Centos ~]# /etc/init.d/sshd status
openssh-daemon (pid 1629) is running...
[root@Centos ~]# netstat -lntup |grep ssh
tcp 0 0 0.0.0.0:22 0.0.0.0: LISTEN 1629/sshd
tcp 0 0 :::22 ::: LISTEN 1629/sshd
[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:ssh->192.168.1.200:50176 (ESTABLISHED)
[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
去远程主机上检查是否有此文件产生
Last login: Sun Aug 28 12:03:30 2016 from 192.168.1.2
[root@localhost ~]# ls /tmp
123.txt pulse-Z24bYtSaCQMb yum.log
[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: 111 869
Swap: 1983 0 1983
[root@Centos ~]# man scp
SCP(1) BSD General Commands Manual
NAME scp - secure copy (remote file copy program)
-P port
-p 保持属性
-r 拷贝目录
[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
[root@localhost ~]# cd /tmp
[root@localhost tmp]# ls
123.txt pulse-Z24bYtSaCQMb tar.gz.20160820 yum.log
use: sftp -oPort=xx 用户@远程主机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/
[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
Linux系统SSH(Secure Shell Protocol)服务
标签:pen inet6 lis 格式 city list 图片 shell linu
原文地址:https://blog.51cto.com/mingongge/2555721