
SSH を使用してサーバーにファイルを送信する必要があります。SSH を使用したことがないので、これは私にとってはイライラする作業です。私は Windows を実行しており、サーバーは Ubuntu を実行しています。
私は ssh2 IP を使用してサーバーに接続し、自分のアカウントでログインしました。ここで、ファイルをサーバー内のフォルダーに送信したいので、フォルダーに移動して次のコマンドを使用しました。
scp test.txt user_name@host_direction server_folder_destination
常に、test.txt に対して 'stat' を実行できない、ファイルが存在しない、などの結果が返されます。
ssh2 がコンピュータのルート (C:) にあるファイルを表示できないと想定し、さらに指定して C:\test.txt を追加しましたが、同じエラーが表示されます。何が起こっているのかわかりません。
何かヒントはありますか?
答え1
scp test.txt user_name@host_direction server_folder_destination
これは正しい構文ではありません。次のようにする必要があります。
scp test.txt user_name@host_direction:server_folder_destination
--:
は、ローカルファイル 'test.txt' をホスト にコピーしhost_direction
、ユーザー に接続してuser_name
保存することを scp に指示しますserver_folder_destination
(デフォルトでは、リモートユーザーのホームディレクトリに相対的になります)。SCP(1)詳細については man ページを参照してください。
答え2
ssh
は、コマンドをリモートで実行するためのものです。リモート ホストとの間でファイルを転送するには、scp
(または) を使用します。sftp
# send text.txt from this machine to /destination/path on remotehost
scp test.txt user@remotehost:/destination/path
# get test.txt from /foo/bar on remote host and store it here as foo.txt
scp user@remotehost:/foo/bar/test.txt foo.txt