首页 > 编程笔记 > Linux命令 阅读:34

Linux ssh命令的用法(附带实例)

在 Linux 环境中,ssh 命令的功能是安全地远程连接服务器主机系统。

作为 OpenSSH 套件中的客户端连接工具,ssh 命令可以让我们轻松地基于 SSH 加密协议进行远程主机访问,从而实现对远程服务器的管理工‍作。

ssh 命令的语法格式如下:
ssh 参数 域名或IP地址
【实例 1】基于 SSH 协议,远程访问服务器主机系统。
[root@Linux ~]# ssh 192.168.10.10
The authenticity of host '192.168.10.10 (192.168.10.10)' can't be established.
ECDSA key fingerprint is SHA256:ZEjdfRjQV8pVVfu0TSYvDP5UvOHuuogMQSDUgLPG3Kc.
Are you sure you want to continue connecting (yes/no)? yes

Warning: Permanently added '192.168.10.10' (ECDSA) to the list of known hosts.
root@192.168.10.10's password: 此处输入远程服务器管理员密码
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Tue Dec 14 08:49:08 2023
[root@linuxprobe ~]#

【实例 2】使用指定的用户身份登录远程服务器主机系统。
[root@Linux ~]# ssh -l linuxprobe 192.168.10.10
linuxprobe@192.168.10.10's password: 此处输入指定用户的密码
Activate the web console with: systemctl enable --now cockpit.socket
[linuxprobe@linuxprobe ~]$

【实例 3】登录远程服务器主机系统后执行一条命令。
[root@Linux ~]# ssh 192.168.10.10 "free -m"
root@192.168.10.10's password: 此处输入远程服务器管理员密码
         total         used      free      shared  buff/cache  available
Mem:      1966         1359        76          21          530         407
Swap:     2047            9      2038

【实例 4】强制使用 v1 版本的 SSH 加密协议连接远程服务器主机:
[root@Linux ~]# ssh -1 192.168.10.10

相关文章