歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

Linux SSH服務 運維

一.基於口令驗證

[root@zyl ~]# cat ~/.ssh/known_hosts

cat: /root/.ssh/known_hosts: No such file or directory

[root@zyl ~]# ls -l ~/ -a

total 14264

dr-xr-x---. 3 root root 4096 Jun 26 19:08 .

dr-xr-xr-x. 32 root root 4096 Jun 28 17:25 ..

drwx-wx-wx. 2 root root 4096 Jun 19 14:06 044dir

-rw--w--w-. 1 root root 0 Jun 19 14:09 044file

-rw-------. 1 root root 1119 Jun 8 19:36 anaconda-ks.cfg

。。。。。。。。。。####沒有ssh

[root@zyl ~]# ssh -p22 [email protected] ##ssh -p端口號 遠程主機用戶@遠程主機ip

The authenticity of host '192.168.21.132 (192.168.21.132)' can't be established.

RSA key fingerprint is 0d:83:2a:1e:5d:e5:b7:1f:bf:9e:65:45:25:7b:77:59.

Are you sure you want to continue connecting (yes/no)? yes##輸入yes

Warning: Permanently added '192.168.21.132' (RSA) to the list of known hosts.

[email protected]'s password: #####密碼

Last login: Tue Jun 28 20:14:59 2016 from 192.168.21.1

[root@zyl ~]# logout

Connection to 192.168.21.132 closed. ##遠程主機關閉

[root@zyl ~]# cat ~/.ssh/known_hosts ##當前主機

192.168.21.132 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAtyd5b2bSoSmJ1d6cBkPOtFvRP+zbG1/6mC8po13u+o5254TNXwCnmRZqehZJRYLxYaSsKBRpV9ogi+r6JX9KXMO40VUS5cDjVSQ1bxldP3Y4a6WrzvGD/jIsEYHosqYlO19keDC1PKO6UTBlOHdj2tuxmD5DMkk+HHxVaHTt5ZNGBheljpNhiGhbxiCIoPtibSRaeZ7RfxSsr9tk4aANEx46tCzb9ph6WKFjgd+iAphLfxFBfcFh1dk3c7g+Xg8RPKd0jZjwWWESLtfZDtt0tM0xMJXaV0rLolsv5mKjs+HSCBsdZl0jKpktijfW1ZKr4CCBOwwmU7QT9fwSEjp9hQ==

[root@zyl ~]#

二.不登陸遠程主機,直接在遠程主機執行命令

[root@zyl ~]# ssh -p22 [email protected] /sbin/ifconfig

[email protected]'s password:

eth0 Link encap:Ethernet HWaddr 00:0C:29:2C:3D:B3

inet addr:192.168.21.132 Bcast:192.168.21.255 Mask:255.255.255.0

三.

(一):1 2####### 拷貝文件

1.推push:

[root@zyl ~]# scp -P22 /oldboy/b.txt [email protected]:/oldboy

源(本機) 目標(遠程服務器)

[email protected]'s password:

b.txt 100% 19 0.0KB/s 00:00

[root@zyl ~]#

2.推pull:

[root@zyl ~]# scp -P22 [email protected]:/oldboy/newfile /oldboy

目標 源

[email protected]'s password:

newfile 100% 0 0.0KB/s 00:00

(二)

[root@zyl oldboy]# scp -P22 -r /oldboy/ [email protected]:/oldboy2 ####### 拷貝目錄 參數-r

[email protected]'s password:

[root@zyl /]# sftp -oport=22 [email protected]

Connecting to 192.168.21.132...

[email protected]'s password: #######密碼

sftp> put a.log ###拷貝文件 sftp拷貝文件用put

Uploading a.log to /root/a.log

a.log 100% 41 0.0KB/s 00:00

sftp>

(三)

客服端上傳文件默認是傳到服務器家目錄

[root@zyl oldboy7]# sftp -oport=22 [email protected]

Connecting to 192.168.21.128...

[email protected]'s password:

sftp> put /oldboy7/oldboy7.txt

Uploading /oldboy7/oldboy7.txt to /root/oldboy7.txt

/oldboy7/oldboy7.txt 100% 12 0.0KB/s 00:00

客服端文件可以上傳到服務器指定目錄

sftp> put /oldboy7/oldboy7.txt /oldboy7

Uploading /oldboy7/oldboy7.txt to /oldboy7/oldboy7.txt

/oldboy7/oldboy7.txt 100% 12 0.0KB/s 00:00

sftp>

客服端下載服務器上的文件是下載到當前處於當前目錄

sftp> get /oldboy8/oldboy8.txt sftp下載文件文件用get

Fetching /oldboy8/oldboy8.txt to oldboy8.txt

sftp> quit

客服端下載服務器上的文件是可以指定下載目錄

[root@zyl /]# sftp -oport=22 [email protected]

Connecting to 192.168.21.128...

[email protected]'s password:

sftp> get /oldboy8/oldboy8.txt /oldboy

Fetching /oldboy8/oldboy8.txt to /oldboy/oldboy8.txt

本文出自 “randolph” 博客,轉載請與作者聯系!

Copyright © Linux教程網 All Rights Reserved