ssh命令详解

1、默认端口

sftp和ssh的默认端口是22

2、语法介绍

ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec] 
    [-D [bind_address:]port] [-e escape_char] [-F configfile] 
    [-I pkcs11] [-i identity_file] [-L [bind_address:]port:host:hostport] 
    [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port] 
    [-R [bind_address:]port:host:hostport] [-S ctl_path] [-W host:port] 
    [-w local_tun[:remote_tun]] [user@]hostname [command]

3、常用参数详解

-b 绑定本地的ip地址,当本地网卡超过一个的时候,会用到这个参数

-D [bind_address:]port 绑定本地的ip地址和端口

-i identity_file 指定私钥文件

-l login_name 指定登录用户名

p port 指定远程机器的端口

4、常用登录方式

1、需要确认对方机器的指纹,然后再登录

[yiifung@master02 .ssh]$ ssh -p 22    yiifung@192.168.168.128
The authenticity of host '192.168.168.128 (192.168.168.128)' can't be established.
ECDSA key fingerprint is SHA256:oU89b+M9k9nmrvN4S4tVfhnk2jKNcLUxu/n7D0id/6Q.
ECDSA key fingerprint is MD5:17:76:e5:ff:05:bc:5f:3d:3d:ff:6b:1a:3e:a6:ab:9c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.168.128' (ECDSA) to the list of known hosts.
yiifung@192.168.168.128's password: 
Last login: Sat Jul  8 08:34:47 2023 from 192.168.168.130
[yiifung@master01 ~]$ 

2、忽略确认对方机器指纹的步骤,直接登录

[yiifung@master02 .ssh]$ ssh -p 22 -oStrictHostKeyChecking=no   yiifung@192.168.168.128
Warning: Permanently added '192.168.168.128' (ECDSA) to the list of known hosts.
yiifung@192.168.168.128's password: 
Last login: Sat Jul  8 08:33:42 2023 from 192.168.168.130
[yiifung@master01 ~]$

ssh -p 22 -oStrictHostKeyChecking=no   yiifung@192.168.168.128
[yiifung@master02 .ssh]$ ssh -p 22 -oStrictHostKeyChecking=no   yiifung@192.168.168.128
Last login: Sat Jul  8 08:32:39 2023 from 192.168.168.130
[yiifung@master01 ~]$

3、登录的过程中执行命令,执行完命令直接退出此次登录 (单引号一定要加上)

[yiifung@master02 .ssh]$ ssh -p 22    yiifung@192.168.168.128   'cd test ; touch hello; ls -l '
yiifung@192.168.168.128's password: 
total 0
-rw-rw-r--. 1 yiifung yiifung 0 Jul  8 08:37 hello
-rw-rw-r--. 1 yiifung yiifung 0 Jul  8 04:39 test1
-rw-rw-r--. 1 yiifung yiifung 0 Jul  8 04:39 test2
[yiifung@master02 .ssh]$ 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值