Windows10で scp コマンドを使ってレンタルサーバ(heteml)にファイルやり取りした際に躓いたところを覚書。
1. ローカルパスはフルパスにする
# NG
scp -P 2222 <Username>@ssh-<id>.heteml.net:<Path> ~\desktop
# > ~/desktop: No such file or directory
# OK
scp -P 2222 <Username>@ssh-<id>.heteml.net:<Path> C:\Users\<User>\desktop
2. ポート番号はオプションで渡す ※位置も注意
hetemlの場合SSHポート番号が 2222
に設定されているのでコマンドも設定を要する。
# NG
scp ~\desktop\<File> <Username>@ssh-<id>.heteml.net:2222<Path>
scp ~\desktop\<File> -P 2222 <Username>@ssh-<id>.heteml.net:<Path>
scp -F <Path>\.ssh\config ~\desktop\<File> <Username>@ssh-<id>.heteml.net:<Path>
# > ssh: connect to host ssh-tokyoweld.heteml.net port 22: Connection timed out
# > lost connection
# OK
scp -P 2222 <Username>@ssh-<id>.heteml.net:<Path> C:\Users\<User>\desktop
3. リモートパスのルートの /
は不要
# NG
scp -P 2222 ~\desktop\<File> <Username>@ssh-<id>.heteml.net:/web/
# > scp: /web/: Is a directory
scp -P 2222 ~\desktop\<File> <Username>@ssh-<id>.heteml.net:/web/<Path>
# > scp: /web/<Path>: No such file or directory
# OK
scp -P 2222 ~\desktop\<File> <Username>@ssh-<id>.heteml.net:web
scp -P 2222 ~\desktop\<File> <Username>@ssh-<id>.heteml.net:web/
scp -P 2222 ~\desktop\<File> <Username>@ssh-<id>.heteml.net:web/<Path>
4. プロトコル(ssh://)は不要
# NG
scp -P 2222 ~\desktop\<File> <Username>@ssh://ssh-<id>.heteml.net:/web/
# > C:\\Windows\\System32\\OpenSSH\\ssh.exe: Could not resolve hostname ssh: \202\273\202\31...
# > lost connection
# OK
scp -P 2222 ~\desktop\<File> <Username>@ssh-<id>.heteml.net:web