Openssh 常见用法

用法:

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

常见参数:

普通的登录

ssh user@remotehost
or
ssh -l user remotehost

proxy

ssh -C -N -D localport username@hostname -p remoteport

mount

sshfs -p remoteport user@localhost:/remotepath localpath

将远程主机的 remotepath 挂载到本地 localpath

umount

fusermount -u localpath

卸载挂载文件

upload

scp localpath/file user@localhost:/remotepath

上传本地 file 到远程的 remotepath

download

scp username@localhost:/remotepath/file localpath

下载远程 file 文件到本地

一般而言,对于常用参数,我们将之写入到 .ssh/config 文件中是个很常用的做法

Host name
    IdentityFile    ~/.ssh/your-private-key
    HostName    ip
    port    21
    User    havanna

Compression yes

如此,连接的时候只要如下即可

ssh name