当前位置: 首页 > Linux

每天学一个Linux命令(59):ssh

时间:2023-04-06 22:46:18 Linux

昨天推荐:每天学一个Linux命令(58):telnet命令介绍ssh(SecureShell)命令是一种安全登录远程系统的协议.在服务器上记录或执行命令。ssh(SSH客户端)是一个用于登录远程计算机并在其上执行命令的程序。它可以在不安全网络中的两个不可信主机之间提供安全的加密通信。语法格式ssh[OPTIONS][-pPORT][USER@]HOSTNAME[COMMAND]选项说明-4#forcessh协议只使用IPv4地址-6#forcessh协议只使用IPv6地址-A#enablefromauthenticationagent连接转发-a#禁用身份验证代理连接的转发-Bbind_interface#在尝试连接到目标主机之前绑定到bind_interface的地址-bbind_address#使用本地计算机上的bind_address作为连接的源地址-C#请求到压缩所有数据-ccipher_spec#指定加密会话的密码规范-D[bind_address:]port#指定本地“动态”应用程序级端口转发-Elog_file#将调试日志附加到log_file而不是标准错误-eescape_char#SetEscapepty会话的字符(默认值:'~')-F配置文件#指定每个用户的ssh配置文件-f#配置ssh在执行命令之前将请求转发到后台-g#允许远程主机连接到本地转发的端口-iidentity_file#指定从该文件中读取用于公钥认证的身份(私钥)-K#启用基于GSSAPI的认证-k#禁用GSSAPI凭证-Llocal_socket:remote_socket#指定转发给定TCP端口的连接或本地(客户端)主机上的Unix套接字到给定的远程主机和端口或Unix套接字。-N#禁止执行远程命令-pport#指定SSH连接端口-q#安静模式-s#用于请求调用远程系统上的子系统-T#禁止分配伪终端-t#强制分配伪终端-V#打印SSH版本号并退出-v#Verbose模式(输出SSH连接的进程信息)-X#启用X11转发-x#禁用X11转发-Y#启用可信X11转发-y#指定发送日志信息syslog(3)系统模块应用示例连接远程主机sshusername@remote_host#ssh使用特定身份(私钥)连接远程主机ssh-ipath/to/key_fileusername@remote_hostuse连接远程主机的特定端口sshusername@remote_host-p9999使用SSH连接远程服务器,运行命令sshremote_hostcommand[root@centos7~]#ssh192.168.1.199lsTheauthenticationofhost'192.168.1.199(192.168.1.199)'无法建立。ECDSA密钥指纹5SHA:mF2QLxkGH/mWhHu/NlaKOrx4nKkyVvhYV6BRPA8TdEk.ECDSA密钥指纹为MD5:a1:91:03:6b:9a:91:f6:c3:cf:19:06:32:19:b9:85:8e.您确定要继续连接吗(是/否)?yesWarning:永久添加'192.168.1.199'(ECDSA)到已知主机列表。root@192.168.1.199的密码:anaconda-ks.cfgdos_test.txtgoinceptiongoInception6-4-v1.2.3.tar.gzhttpdhttpd-2.4.46httpd-2.4.46.tar.gzmingongge.filemingongge.z01mingongge.z02mingongge.ziptestdirtest.txt查看一下SSH远程登录过程的详细信息[root@centos7~]#ssh-v192.168.1.199-p22OpenSSH_7.4p1,OpenSSL1.0.2k-fipsetc1:7readingbug26reading2/ssh/ssh_configdebug1:/etc/ssh/ssh_config行58:为*debug1应用选项:连接到192.168.1.199[192.168.1.199]端口22.debug1:已建立连接。debug1:permanently_set_uid:0/0debug_load_1:没有公钥文件或目录debug1:身份文件/root/.ssh/id_rsa类型-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_rsa-cert类型-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_dsatype-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_dsa-certtype-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_ecdsatype-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_ecdsa-certtype-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_ed25519type-1debug1:key_load_public:没有这样的文件或目录debug1:身份文件/root/.ssh/id_ed25519-certtype-1debug1:?Enabling?compatibility?mode?for?protocol?2.0debug1:?Local?version?string?SSH-2.0-OpenSSH_7.4debug1:?Remote?protocol?version?2.0,?remote?software?version?OpenSSH_7.4debug1:?match:?OpenSSH_7.4?pat?OpenSSH*?compat?0x04000000debug1:?Authenticating?to?192.168.1.199:22as?'root'debug1:?SSH2_MSG_KEXINIT?sentdebug1:?SSH2_MSG_KEXINIT?receiveddebug1:?kex:?algorithm:?curve25519-sha256debug1:?kex:?host?key?algorithm:?ecdsa-sha2-nistp256debug1:?kex:?server->client?cipher:?chacha20-poly1305@openssh.com?MAC:?compression:nonedebug1:kex:client->servercipher:chacha20-poly1305@openssh.comMAC:compression:nonedebug1:kex:curve25519-sha256need=64dh_need=64debug1:kex:curve25519-sha256need=64?dh_need=64debug1:?expecting?SSH2_MSG_KEX_ECDH_REPLYdebug1:?Server?host?key:?ecdsa-sha2-nistp256?SHA256:mF2QLxkGH/mWhHu/NlaKOrx4nKkyVvhYV6BRPA8TdEkdebug1:?Host?'192.168.1.199'?is?known?and?matches?the?ECDSA?host?key.debug1:?Found?key?in?/root/.ssh/known_hosts:1debug1:?rekey?after?134217728?blocksdebug1:?SSH2_MSG_NEWKEYS?sentdebug1:?expecting?SSH2_MSG_NEWKEYSdebug1:?SSH2_MSG_NEWKEYS?receiveddebug1:?rekey?after?134217728?blocksdebug1:?SSH2_MSG_EXT_INFO?receiveddebug1:?kex_input_ext_info:?server-sig-algs=debug1:SSH2_MSG_SERVICE_ACCEPT收到debug1:可以继续的身份验证:publickey,gssapi-keyex,gssapi-with-mic,passworddebug1:下一个身份验证方法:gssapi-keyexdebug1:没有有效的密钥交换contextdebug1:下一个身份验证未指定的Gbugpi方法:with-gsss失败。次要代码可能会提供更多信息没有可用的Kerberos凭证(默认缓存:KEYRING:persistent:0)debug1:未指定的GSS故障。次要代码可能会提供更多信息没有可用的Kerberos凭据(默认缓存:KEYRING:持久性:0)debug1:下一个身份验证方法:publickeydebug1:尝试私钥:/root/.ssh/id_rsadebug1:尝试私钥:/root/.ssh/id_dsadebug1:尝试私钥:/root/.ssh/id_ecdsadebug1:尝试私钥:/root/.ssh/id_ed25519debug1:下一步验证方法:passwordroot@192.168.1.199的密码:debug1:验证成功(密码).Authenticated.1to6.1921.199([192.168.1.199]:22).debug1:channel0:new[client-session]debug1:Requestingno-more-sessions@openssh.comdebug1:Enteringinteractivesession.debug1:pledge:networkdebug1:client_input_global_request:rtypehostkeys-00@openssh.comwant_reply0debug1:发送environment.debug1:发送envLANG=en_US.UTF-8Lastlogin:Sun1714:26:282021from192.168.1.93每天学一个Linux命令(55):id每天学Linux命令(56):su/sudo每天学一个Linux命令(57):cal