1. ssh client simple to use
ssh [-p port] user@remote
- user: user name on the remote machine, if not specified, the default is the current user
- remote: remote machine address, can be
IP/域名
- port: SSH Server listening port, if not specified, the default value
22
prompt:
- Use
exit
the log off the current user- If the
Windows
system can be installedPuTTY
orXShell
client softwareprompt:
- In total work, SSH server port number is likely
不是22
, if this happens you need to use the-p
option to specify the correct port number, or can not properly connected to the server
2. scp remote copy command
scp: secure copy
, carried out at a used Linux 远程拷贝文件
commands
# 把本地当前目录下的文件 复制到远程 用户目录下的Desktop
# 注意: `:` 后面的路径如果不是绝对路径, 则以用户的home目录作为参照路径
scp -P port fileName user@remote:Desktop
# 把远程 home目录下的 Desktop/file 文件 复制到 本地当前目录下的 file
scp -P port user@remote:Desktop/file file
# 加上 -r 选项可以传送文件夹
# 把当前目录下的 demo文件夹 复制到 远程 home目录下的 Desktop
scp -r demo user@remote:Desktop
# 把远程 home目录下的Desktop 复制到当前目录下的 demo 文件夹
scp -r user@remote:Desktop demo
Options | meaning |
---|---|
-r | If the source file is a directory given file, scp will copy recursively all directories and files in the directory, the target file must be a directory name |
-P | If the remote SSH server port is not 22, you need to use capital letters -P option to specify a port |
example:
$ scp -P 8088 -r [email protected]:data demo
Explained:
-P: specify port
8088: The port number
-r: copy the folder
ClearLight: the User
217.32.211.58:data: Remote address: The current data file in the user directory folder
demo: demo copy to the files in the current directory folder in
3. SSH Advanced Tutorial
- Free Password
- Configuring an Alias
Tip: For SSH configuration information is stored in the user's home directory
.ssh
directory
Password 3.1 free
step:
- Public key configuration
- Execution
ssh-keygen
to generate SSH keys all the way round to
- Execution
- Upload the public key to the server
- Execution
ssh-copy-id -p port user@remote
, allows remote server to remember our public key
- Execution
3.2 Configuring an Alias
step:
-
In
.ssh
the new config file in the folder, and then write the following contentHost Alias
HostName ip address / domain name
User Username
Port 22
-
At this point, you can use
ssh 别名
remote login,scp
you can also be used.lixiaoyi@T470p:~$ cd .ssh lixiaoyi@T470p:~/.ssh$ ls id_rsa id_rsa.pub known_hosts lixiaoyi@T470p:~/.ssh$ touch config lixiaoyi@T470p:~/.ssh$ vim config lixiaoyi@T470p:~/.ssh$ cat config Host clearlight HostName www.clearlight.top User clearlight port 22 lixiaoyi@T470p:~/.ssh$ ssh clearlight Last login: Sun Jan 12 13:10:07 2020 from 106.8.66.188 Welcome to Alibaba Cloud Elastic Compute Service ! [clearlight@iz2ze7n4ftkcqan59957w2z ~]$