Site cover image

Site icon image 制作メモ

Description is here. The icon, the title, the description can be modified in Notion.

[Linux] ssh でファイルをアップロードする

鍵認証のssh 接続で ~/.ssh/config でエイリアスを設定している場合の scp コマンドの使い方です。

Dドライブの test ディレクトリにある index.html をサーバーの /var/www/ に転送する場合を例にとって説明します。

まずはファイルのあるディレクトリに移動します。

$ cd D:/test/

そして scp コマンドを使います。使い方はこう。

$ scp 【ローカルにあるファイルのパス】 【ユーザー名】@【configで設定したエイリアス名】:【転送先のディレクトリ 例:/var/www/

仮に ~/.ssh/config の設定が

Host 560designs
    HostName 127.0.0.1
    User www
    TCPKeepAlive yes
    IdentitiesOnly yes
    IdentityFile ~/.ssh/id_rsa
    Port 22

このようになっているとしたら、

$ scp index.html www@560designs:/var/www/

こう。

これで index.html が /var/www/ にアップロードされます。

ちなみにアップロードに成功するとこんな結果が返ってきます。

index.html                                    100%   13KB 907.8KB/s   00:00