ubuntu

Ubuntu SSH命令大全及用法

小樊
54
2025-03-12 07:38:57
栏目: 智能运维

在Ubuntu系统中,SSH(Secure Shell)是一个用于加密客户端与服务器之间链接的加密协议,可以安全地进行远程访问和文件传输。以下是一些常用的SSH命令及其用法:

  1. 安装OpenSSH服务器

    sudo apt update
    sudo apt install openssh-server
    
  2. 检查SSH服务状态

    sudo systemctl status ssh
    
  3. 启动SSH服务

    sudo systemctl start ssh
    
  4. 停止SSH服务

    sudo systemctl stop ssh
    
  5. 启用SSH服务(开机自启动)

    sudo systemctl enable ssh
    
  6. 禁用SSH服务

    sudo systemctl disable ssh
    
  7. 连接到SSH服务器

    ssh username@ip_address
    
  8. 免密登录

    • 生成密钥对:
      ssh-keygen
      
    • 将公钥复制到远程主机:
      ssh-copy-id username@ip_address
      
  9. 配置防火墙

    • 允许SSH端口(默认22):
      sudo ufw allow ssh
      
  10. 查看服务器IP

    ip addr show
    

0
看了该问题的人还看了