nothing to say.. @caizhiyuannn@gmail.com
$ ssh user@host
The authenticity of host 'host(192.168.1.1)' cann't be established.
RSA key fingerprint is 98:2e:d7:e0:de:9f:ac:67:28:c2:42:2d:37:16:58:4d.
Are you sure you want to continue connecting (yes/no)?
系统出现一句提示,表示主机已经得到认可。
Warning: Permanently added 'host,192.168.1.1' (RSA) to the list of known hosts.
然后提示输入密码。
Password:(enter password)
SSH 登陆
$ ssh user@host
语法:
ssh [-1246AaCfGgKkMNnqsTtVvXxYy] [user@]hostname [command]
传输公钥
$ ssh user@host 'mkdir -p .ssh && cat >> .ssh/authorized_keys' < ~/.ssh/id_rsa.pub
复制文件
$ cd && tar czv src | ssh user@host 'tar xz'
$ ssh user@host 'tar cz src' | tar xzv
关机。。。
$ ssh root@host 'poweroff'
绑定本地端口
$ ssh -D 7777 user@host
本地端口转发技术 host1 -> host3 -> host2
$ ssh -L 7777:host2:21 host3
$ ftp localhost:7777
SSH隧道技术
$ ssh -L 7777:localhost:7777 host3
SSH -L 语法
$ ssh -L local_port:remote_host:remote_port connect_host
远程端口转发技术 host1 -> host2, host1 -> host3 , host2 -> host1 -> host3
host1 $ ssh -R 7777:host3:21 host2
host2 $ ssh -p 7777 localhost
ssh -R 语法
$ ssh -R open_remote_port:remote_host:remote_port connect_host
host2 和 host3 必须都有sshd 和 ssh client。
$ ssh -NT -D 8080 host
N 表示只打开远程连接,不打开shell操作
T 表示不为该连接分配TTY 连接
$ ssh -f -D 8080 host