ssh 命令详解 (未集成)

SSH 为 Secure Shell 的缩写。

SSH 是建立在应用层基础之上,专为远程登录会话和其它网络服务提供的可靠安全协议。

另请参阅: scp     Documentation

Basic Usage     Detailed Usage     异常处理

ssh root@47.99.XX.XX
			

基本语法

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

选项参数

参数 EN 解释 中文翻译 Remark

Basic Usage

Function 命令 文字解释 示例 示例解释
登陆 ssh username@<固定公网IP或EIP> 远程登陆 username ssh root@47.99.XX.XX 键入口令远程登陆 root
ssh username@192.168.1.112:22 远程登陆 username
ssh://username:******@192.168.1.112:22 远程登陆 username (* 表示口令)
帮助 ssh --help 展示帮助信息

Detailed Usage

安装
apt-get install openssh-server
 
Version
dpkg -l openssh-server
 
进程
ps -e | grep ssh
			
停止
/etc/init.d/ssh stop
 
重载
systemctl reload sshd 或 rcctl reload sshd
systemctl restart sshd
 
启动
/etc/init.d/ssh start 或 service ssh start
 
重启
/etc/init.d/ssh restart 或 service sshd restart
			

SSH 服务器配置

日志
vi /var/log/auth.log
 
配置
vi /etc/ssh/sshd_config
			

SSH 服务器默认端口 22,可自定义成其它端口号,如:222

异常处理

received:3,expected:20 错误

Xshell 5 以 SSH 协议连接 Ubuntu 20.04 (或麒麟 Kylin V10) 提示以上错误, 解决方法:

KexAlgorithms curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group14-sha1
			

在 /etc/ssh/sshd_config 文件末尾,添加以上行, 然后重启 openssh 服务器

systemctl reload sshd 或 rcctl reload sshd
 
systemctl restart sshd
			

 

Copyright Notice: This article is an exclusive original manuscript, copyright belongs to Happy Digits Software , shall not be reproduced without permission.