이 콘텐츠는 선택한 언어로 제공되지 않습니다.
Chapter 15. Remote
Apache Karaf supports a complete remote mechanism allowing you to remotely connect to a running Apache Karaf instance. You can also browse, download, and upload files remotely to a running Apache Karaf instance.
Apache Karaf embeds a complete SSHd server.
15.1. SSHd server 링크 복사링크가 클립보드에 복사되었습니다!
When you start Apache Karaf, it enables a remote console that can be accessed over SSH.
This remote console provides all the features of the "local" console, and gives a remote user complete control over the container and services running inside of it. As the "local" console, the remote console is secured by a RBAC mechanism See Chapter 19, Security for details.
In addition to the remote console, Apache Karaf also provides a remote filesystem. This remote filesystem can be accessed using a SCP/SFTP client.
15.1.1. Configuration 링크 복사링크가 클립보드에 복사되었습니다!
The configuration of the SSHd server is stored in the etc/org.apache.karaf.shell.cfg file:
The etc/org.apache.karaf.shell.cfg configuration file contains different properties to configure the SSHd server:
-
sshPortis the port number where the SSHd server is bound (by default, it’s 8101). -
sshHostis the address of the network interface where the SSHd server is bound. The default value is 0.0.0.0, meaning that the SSHd server is bound on all network interfaces. You can bind on a target interface providing the IP address of the network interface. -
hostKeyis the location of thehost.keyfile. By defaut, it usesetc/host.key. This file stores the public and private key pair of the SSHd server. -
sshRoleis the default role used for SSH access. The default value is the value ofkaraf.admin.roleproperty defined inetc/system.properties. See the [Security section|security] of this user guide for details. -
keySizeis the key size used by the SSHd server. The possible values are 1024, 2048, 3072, or 4096. The default value is 1024. -
algorithmis the host key algorithm used by the SSHd server. The possible values are DSA or RSA. The default value is DSA.
The SSHd server configuration can be changed at runtime:
-
by editing the
etc/org.apache.karaf.shell.cfgconfiguration file -
by using the
config:*commands
At runtime, when you change the SSHd server configuration, you have to restart the SSHd server to load the changes. You can do it with:
karaf@root()> bundle:restart -f org.apache.karaf.shell.ssh
karaf@root()> bundle:restart -f org.apache.karaf.shell.ssh
The Apache Karaf SSHd server supports key/agent authentication and password authentication.
15.1.2. Console clients 링크 복사링크가 클립보드에 복사되었습니다!
15.1.2.1. System native clients 링크 복사링크가 클립보드에 복사되었습니다!
The Apache Karaf SSHd server is a pure SSHd server, similar to OpenSSH daemon.
It means that you can use directly a SSH client from your system.
For instance, on Unix, you can directly use OpenSSH:
On Windows, you can use Putty, Kitty, etc.
If you don’t have SSH client installed on your machine, you can use Apache Karaf client.
15.1.2.2. ssh:ssh command 링크 복사링크가 클립보드에 복사되었습니다!
Apache Karaf itself provides a SSH client. When you are on the Apache Karaf console, you have the ssh:ssh command:
Thanks to the ssh:ssh command, you can connect to another running Apache Karaf instance:
When you don’t provide the command argument to the ssh:ssh command, you are in the interactive mode: you have a complete remote console available, where you can type commands, etc.
You can also provide directly a command to execute using the command argument. For instance, to remotely shutdown a Apache Karaf instance:
karaf@root()> ssh:ssh -p 8101 karaf@localhost system:shutdown -f Connecting to host localhost on port 8101 Connected
karaf@root()> ssh:ssh -p 8101 karaf@localhost system:shutdown -f
Connecting to host localhost on port 8101
Connected
As the ssh:ssh command is a pure SSH client, so it means that you can connect to a Unix OpenSSH daemon:
15.1.2.3. Apache Karaf client 링크 복사링크가 클립보드에 복사되었습니다!
The ssh:ssh command requires to be run into a running Apache Karaf console.
For commodity, the ssh:ssh command is "wrapped" as a standalone client: the bin/client Unix script (bin\client.bat on Windows).
For instance, to connect to local Apache Karaf instance (on the default SSHd server 8101 port), you can directly use bin/client Unix script (bin\client.bat on Windows) without any argument or option:
When you don’t provide the command argument to the bin/client Unix script (bin\client.bat on Windows), you are in the interactive mode: you have a complete remote console available, where you can type commands, etc.
You can also provide directly a command to execute using the command argument. For instance, to remotely shutdown a Apache Karaf instance:
bin/client "system:shutdown -f" Logging in as karaf 330 [pool-2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /0.0.0.0:8101 presented unverified key:
bin/client "system:shutdown -f"
Logging in as karaf
330 [pool-2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /0.0.0.0:8101 presented unverified key:
As the Apache Karaf client is a pure SSH client, you can use to connect to any SSHd daemon (like Unix OpenSSH daemon):
15.1.2.4. Logout 링크 복사링크가 클립보드에 복사되었습니다!
When you are connected to a remote Apache Karaf console, you can logout using:
- using CTRL-D key binding. Note that CTRL-D just logout from the remote console in this case, it doesn’t shutdown the Apache Karaf instance (as CTRL-D does when used on a local console).
-
using
shell:logoutcommand (or simplylogout)
15.1.3. Filsystem clients 링크 복사링크가 클립보드에 복사되었습니다!
Apache Karaf SSHd server also provides complete fileystem access via SSH. For security reason, the available filesystem is limited to KARAF_BASE directory.
You can use this remote filesystem with any SCP/SFTP compliant clients.
15.1.3.1. Native SCP/SFTP clients 링크 복사링크가 클립보드에 복사되었습니다!
On Unix, you can directly use scp command to download/upload files to the Apache Karaf filesystem. For instance, to retrieve the fuse.log file remotely:
As you have access to the complete KARAF_BASE directory, you can remotely change the configuration file in the etc folder, retrieve log files, populate the system folder.
On Windows, you can use WinSCP to access the Apache Karaf filesystem.
It’s probably easier to use a SFTP complient client.
For instance, on Unix system, you can use lftp or ncftp:
You can also use graphic client like filezilla, gftp, nautilus, etc.
On Windows, you can use filezilla, WinSCP, etc.
15.1.3.2. Apache Maven 링크 복사링크가 클립보드에 복사되었습니다!
The Apache Karaf system folder is the Karaf repository, that use a Maven directory structure. It’s where Apache Karaf looks for the artifacts (bundles, features, kars, etc).
Using Apache Maven, you can populate the system folder using the deploy:deploy-file goal.
For instance, you want to add the Apache ServiceMix facebook4j OSGi bundle, you can do:
mvn deploy:deploy-file -Dfile=org.apache.servicemix.bundles.facebook4j-2.0.2_1.jar -DgroupId=org.apache.servicemix.bundles -DartifactId=org.apache.servicemix.bundles.facebook4j -Dversion=2.0.2_1 -Dpackaging=jar -Durl=scp://localhost:8101/system
mvn deploy:deploy-file -Dfile=org.apache.servicemix.bundles.facebook4j-2.0.2_1.jar -DgroupId=org.apache.servicemix.bundles -DartifactId=org.apache.servicemix.bundles.facebook4j -Dversion=2.0.2_1 -Dpackaging=jar -Durl=scp://localhost:8101/system
15.2. JMX MBeanServer 링크 복사링크가 클립보드에 복사되었습니다!
Apache Karaf provides a JMX MBeanServer.
This MBeanServer is available remotely, using any JMX client like jconsole.
You can find details on the [Monitoring section|monitoring] of the user guide.