--Environment --Connection source - CentOS Linux release 7.6.1810 (Core) - OpenSSH_7.4p1, OpenSSL 1.0.2k-fips 26 Jan 2017 --Step host: Amazon Linux release 2 (Karoo) --Location host: Red Hat Enterprise Linux Server release 5.11 (Tikanga)
It is troublesome to transfer files from the connection source to the stepping stone, from the stepping stone to the storage place.
Proxy Command
on SCP--Reference --ssh / scp multi-stage connection ~ Beyond the bastion server ~ --Qiita -Multi-stage scp connection via stepping stone with key authentication --Kabegiwa Blog
format
#Example) Transfer all files with the extension jar in a specific directory
# -r :Recursively copy in the directory.
# -o :setting file(ssh_config)Pass options to ssh in the format used in
# -W : %h and%Replace p with the original destination and its port
$ scp -i {Storage key} -r -o ProxyCommand='ssh -i {Step key} -W %h:%p {Stepping stone user}@{Stepping stone address}' {Your directory path}/*.jar {Storage user}@{Storage address}:{Storage directory path}
Similarly with SSH, if you connect in multiple stages using ProxyCommand
, you can log in to the host on the other side of the platform with a single shot.
#Transfer files with SCP
$ scp -i ~/.ssh/fumidai.pem -r -o ProxyCommand='ssh -i ~/.ssh/okiba.pem [email protected] -W %h:%p' /home/ponsuke/HOGE.war [email protected]:/tmp/.
Enter passphrase for key '/home/ponsuke/.ssh/fumidai.pem':
Enter passphrase for key '/home/ponsuke/.ssh/okiba.pem':
HOGE.war 100% 38MB 44.2MB/s 00:00
Killed by signal 1.
#I will go to check the file that was connected to SSH
$ ssh -i ~/.ssh/fumidai.pem -o ProxyCommand='ssh -i ~/.ssh/ponsuke.pem [email protected] -W %h:%p' [email protected]
Enter passphrase for key '/home/ponsuke/.ssh/fumidai.pem':
Enter passphrase for key '/home/ponsuke/.ssh/okiba.pem':
Last login: Thu Apr 2 14:49:44 2020 from 10.0.3.182
#Was sent properly
$ ls /tmp/
HOGE.war
Recommended Posts