ssh -p 6887 -i /home/project01/Project01
[email protected]
一、ssh简介
传统的FTP、POP、Telent是不安全的,他们在网络上是用明文来传输数据的。ssh是安全的,可以对所有的传输数据进行加密。
ssh(security Shell的简称) 分为客户端和服务端,在使用的时候需要服务端打开ssh服务端口,客户端就可以连接使用了。
ssh
(SSH client) is a program for logging into a remote machine and for
executing commands on a remote machine. It is intended to replace rlogin
and rsh, and provide secure encrypted communications between two
untrusted hosts over an insecure network. X11 connections and arbitrary
TCP/IP ports can also be forwarded over the secure channel.
ssh connects and logs into the specified hostname (with optional user
name). The user must prove his/her identity to the remote machine using
one of several methods depending on the protocol version used.
If command is specified, command is executed on the remote host instead
of a login shell.
例如:
ssh
[email protected]
系统默认不允许以root用户远程登录的,如果想使root可以登录,要将/etc/ssh/sshd_config文件的permitRootlogin no中的no改为yes,然后重新启动ssh服务;
二、scp简介
scp - secure copy (remote file copy program)
scp copies files between hosts on a network. It uses ssh(1) for data
transfer, and uses the same authentication and provides the same security
as ssh(1). Unlike rcp(1), scp will ask for passwords or passphrases if
they are needed for authentication.
分两种情况:
1.设要把 A上的 /root/abc.zip 传到 B机并放到/abc目录,可以在A机上用命令
scp /root/abc.zip
[email protected]:/abc/
若 SSH端口不是默认的22,比如,是端口1234 则加-P参数:
scp -P 1234 /root/abc.zip
[email protected]:/abc/
如果要赋值目录可以加一个 -r 选项
scp -r /root/abc.zip
[email protected]:/abc/
2.也可以在B机上用命令:
scp
[email protected]:/root/abc.zip /abc/
基本要求:双方机子只要启动ssh服务即可。
三、sftp简介
sftp - secure file transfer program
sftp is an interactive file transfer program, similar to ftp(1), which
performs all operations over an encrypted ssh(1) transport. It may also
use many features of ssh, such as public key authentication and compression. sftp connects and logs into the specified host, then enters an
interactive command mode.
bye Quit sftp.
cd path
Change remote directory to path.
rm filename
delete remote files
!command
在本地环境执行命令,不是在远端执行
exit Quit sftp.
get [-P] remote-path [local-path]
help Display help text.
lcd path
Change local directory to path.
lls [ls-options [path]]
ls [path]
put [-P] local-path [remote-path]
pwd Display remote working directory.
quit Quit sftp.
在本地执行的命令前面都要带l,带远端执行的命令不用带l;
四、
locate passwd
但与find 不同: find 是去硬盘找.
locate 只在/var/lib/slocate资料库中找
locate的速度比find快,它并不是真的查找,而是查数据库,一般文件数据库在/var/lib/slocate/slocate.db中,所以locate的查找并不是实时的,而是以数据库的更新为准,一般是系统自己维护,也可以手工升级数据库 updatedb.但这个数据库不是随时更新的。因此有updatedb命令来将这个数据库及时更新。那么就可以找到最新增加的文件了。
五、
ifconfig 是一个用来查看、配置、启用或禁用网络接口的工具.
If no arguments are given, ifconfig displays the status of the currently active interfaces. If a single interface argument is given, it displays
the status of the given interface only; if a single -a argument is given, it displays the status of all interfaces, even those that are down.
Otherwise, it configures an interface.