ssh的简单使用

所属客户端联机程序 -Linux客户端


ssh [ -f ]  [ -o  参数项目 ]  [ -p 非正规端口 ] [ 账号 ]  IP  [ 指令 ]


-f : 需要配合后面的指令 ,不登入远程主机直接发送一个指令而已


-o 参数项目 :  主要的参数项目有:

ConnectTimeout=秒数  : 联机等待的时间


StrictHiostKeyChecking=[ yes | no | ask ]  默认是ask 


-p : 如果你的sshd服务器启动在非正规的饿端口(22)  ,需要此项目;

指令 : 不登陆远程主机直接发送只ing过去(与-f 不同)



example:

使用账号登陆到远程主机


ssh   user_name@IP_number


只发送指令而不登陆远程主机

ssh -f root@172.16.121.135 shutdown -h now



===========================================

摸你 FTP的文件传输方式: sftp


ssh是使用远程服务器进行工作,如果你只想从远程服务器下载或者上传资料,那就需要使用sftp或scp.这两个指令也都是使用ssh的22

号端口,只是模拟成FTP与复制的动作而已.


sftp  user_name@IP_number  


进入到sftp后可以通过指令进行相关操作


get  [-Ppr]


put [-Ppr] local-path [remote-path]

             Upload local-path and store it on the remote machine.  If the

             remote path name is not specified, it is given the same name it

             has on the local machine.  local-path may contain glob(3) charac-

             ters and may match multiple files.  If it does and remote-path is

             specified, then remote-path must specify a directory.


             If either the -P or -p flag is specified, then full file permis-

             sions and access times are copied too.


             If the -r flag is specified then directories will be copied

             recursively.  Note that sftp does not follow symbolic links when

             performing recursive transfers.



sftp的功能和指令很多,详情请自己man一下

============================================

异地复制: scp

通常使用sftp是因为可能不知道服务器上有什么文件存在,如果已经能知道服务器上的文件名了,那么可以直接用scp复制过来

scp [ -pr ]  [ -l 速率 ]  file 账号@IP_nubmber  

-p : 保留源文件的权限数据

-r : 复制目录

-l : 可以 限制传输的速度


example:

将本机的/etc/*下面的文件 全复制到 远程主机的/root/user_etc上


scp  /etc/*  user@172.16.121.135:/root/user_etc/


将远程主机上的/etc复制到本机的 /root/etc下


scp -r  root@172.16.121.135:/etc  /tmp 


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值