サーバはポート「8765」でリッスンしており、認証にはSSHキーが必要です。
以下を使用してリモートディレクトリをマウントできます。
sshfs -o idmap=user,port=8765 stephen@server:/export/usb2T /mnt/usb2T
サーバーは私のSSH公開鍵を認識します。
標準 SSH ポートの fstab エントリは次のとおりです。
stephen@server:/export/inbox /mnt/inbox fuse.sshfs defaults,_netdev 0 0
ただし、サーバーのリッスンポートとクライアントユーザーのSSH公開鍵を追加する必要があります。
どうすればいいですか?
ベストアンサー1
/etc/fstab
探している項目は次のとおりです。
使用法,port=PORTNUMBER
と,IdentityFile=/root.ssh/id_rsa
オプション:
sshfs#USER@IP-ADDRESS:/export/inbox /mnt/inbox fuse.sshfs delay_connect,_netdev,user,IdentityFile=/root.ssh/id_rsa,idmap=user,allow_other,default_permissions,port=PORTNUMBER,uid=0,gid=0,rw,nosuid,nodev 0 0
ssh
以下を介してSSHFS
リモートからディレクトリをマウントする
- 上記のようにSSHキーを設定すると、インストール中にパスワードを入力する必要はありません。これにより、インストールがはるかに簡単になり、スクリプトを使用したりローカルコンピュータにログインしたりするときに自動的に実行できます。
- SSHと同様に、ローカルコンピュータとリモートコンピュータ間のすべてのトラフィックは暗号化されます。
- ローカルコンピュータの管理者である場合は、コンピュータの起動時にこのタスクを実行して、常にインストールするようにシステムを設定できます。次の行を追加して/etc/fstabを変更する必要があります(ただし、すべて1行にあります)。
- また、これを行うにはSSHキーを設定する必要があり、パスワードを入力する必要はありません。オプションの説明については、SSHFS のマニュアルページを参照してください。上記のfstab行が機能しない場合(起動時にエラーメッセージが表示される)、次のように修正できます(noautoの追加に注意してください)。
sshfs#USER@IP-ADDRESS: /export/inbox fuse defaults,user,noauto,
uid=einstein,gid=einstein,allow_other,IdentityFile=/home/alfred/.ssh/id_dsa 0 0
sshfs#USER@IP-ADDRESS: /export/inbox fuse defaults,user,uid=USER,gid=USER,allow_other,IdentityFile=/home/USER/.ssh/id_dsa 0 0
fstabにsshfsリモートディレクトリをマウントする方法
mount -aなしでfstabを使用してsshfsを自動的にマウントします。
SSHFSは、レビューできる多くのコマンドラインオプションを受け入れます。たとえば、リモートシステムのSSHサーバーがポート22ではなくポート12345で実行されている場合は、次のようにします。
sshfs USER@IP-ADDRESS: /export/inbox -p PORTNUMBER
コマンドラインオプションは次のとおりです。
SSHFSオプション:
-p PORT
equivalent to '-o port=PORT'
-C
equivalent to '-o compression=yes'
-F ssh_configfile
specifies alternative ssh configuration file
-1
equivalent to '-o ssh_protocol=1'
-o reconnect
reconnect to server
-o delay_connect
delay connection to server
-o sshfs_sync
synchronous writes
-o no_readahead
synchronous reads (no speculative readahead)
-o sshfs_debug
print some debugging information
-o cache=BOOL
enable caching {yes,no} (default: yes)
-o cache_timeout=N
sets timeout for caches in seconds (default: 20)
-o cache_X_timeout=N
sets timeout for {stat,dir,link} cache
-o workaround=LIST
colon separated list of workarounds
none
no workarounds enabled
all
all workarounds enabled
[no]rename
fix renaming to existing file (default: off)
[no]nodelaysrv
set nodelay tcp flag in ssh (default: off)
[no]truncate
fix truncate for old servers (default: off)
[no]buflimit
fix buffer fillup bug in server (default: on)
-o idmap=TYPE
user/group ID mapping, possible types are:
none
no translation of the ID space (default)
user
only translate UID of connecting user
file
translate UIDs/GIDs based upon the contents of uidfile and gidfile
-o uidfile=FILE
file containing username:uid mappings for idmap=file
-o gidfile=FILE
file containing groupname:gid mappings for idmap=file
-o nomap=TYPE
with idmap=file, how to handle missing mappings
ignore
don't do any re-mapping
error
return an error (default)
-o ssh_command=CMD
execute CMD instead of 'ssh'
-o ssh_protocol=N
ssh protocol to use (default: 2)
-o sftp_server=SERV
path to sftp server or subsystem (default: sftp)
-o directport=PORT
directly connect to PORT bypassing ssh -o slave communicate over stdin and stdout bypassing network
-o transform_symlinks
transform absolute symlinks to relative
-o follow_symlinks
follow symlinks on the server
-o no_check_root
don't check for existence of 'dir' on server
-o password_stdin
read password from stdin (only for pam_mount!)
-o SSHOPT=VAL
ssh options (see man ssh_config)