您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
SSH(Secure Shell)是一种加密的网络传输协议,用于在不安全的网络中安全地进行远程登录和其他网络服务。以下是一些常见的SSH命令及其用途:
连接到远程服务器
ssh username@hostname
username 是远程服务器的用户名。hostname 是远程服务器的IP地址或域名。使用密钥认证连接
ssh -i /path/to/private_key username@hostname
-i 指定私钥文件路径。保持连接活跃
ssh -o ServerAliveInterval=60 username@hostname
断开连接
exit 或按 Ctrl+D。使用SCP复制文件到本地
scp username@hostname:/path/to/remote/file /path/to/local/directory
使用SCP从本地复制文件到远程
scp /path/to/local/file username@hostname:/path/to/remote/directory
使用SFTP进行交互式文件传输
sftp username@hostname
在远程服务器上执行单个命令
ssh username@hostname 'command'
在远程服务器上执行多个命令
ssh username@hostname 'command1; command2'
本地端口转发
ssh -L local_port:remote_host:remote_port username@hostname
远程端口转发
ssh -R remote_port:local_host:local_port username@hostname
动态端口转发(SOCKS代理)
ssh -D local_port username@hostname
查看SSH配置文件
ssh -F /path/to/config username@hostname
查看SSH版本
ssh -V
查看SSH连接日志
ssh -vvv username@hostname
使用SSH代理转发
ssh -A username@hostname
使用SSH密钥认证并禁用密码认证
编辑远程服务器的 sshd_config 文件:
PasswordAuthentication no
PubkeyAuthentication yes
然后重启SSH服务:
sudo systemctl restart sshd
希望这个速查表能帮助你快速掌握SSH的基本操作!如果有更多问题,欢迎随时提问。
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。