8.2. Connecting and Disconnecting Remotely
Abstract
8.2.1. Connecting to a Standalone Container from a Remote Container
Overview
Using the ssh:ssh console command
Example 8.2. ssh:ssh Command Syntax
ssh:ssh
{
-l username
} {
-P password
} {
-p port
} {
hostname
}
-
-l username
- The username used to connect to the remote container. Use valid JAAS login credentials that have
admin
privileges (see Chapter 14, Configuring JAAS Security). -
-P password
- The password used to connect to the remote container.
-
-p port
- The SSH port used to access the desired container's remote console.By default this value is
8101
. See the section called “Configuring a standalone container for remote access” for details on changing the port number. -
hostname
- The hostname of the machine that the remote container is running on. See the section called “Configuring a standalone container for remote access” for details on changing the hostname.
etc/users.properties
file. See Chapter 14, Configuring JAAS Securityfor details.
Example 8.3. Connecting to a Remote Console
JBossFuse:karaf@root>ssh:ssh -l smx -P smx -p 8108 hostname
shell:info
at the prompt. Information about the currently connected instance is returned, as shown in Example 8.4, “Output of the shell:info Command”.
Example 8.4. Output of the shell:info Command
Karaf Karaf version 2.2.5.fuse-beta-7-052 Karaf home /Volumes/ESB/jboss-fuse-full-6.0.0.redhat-0XX Karaf base /Volumes/ESB/jboss-fuse-full-6.0.0.redhat-0XX/instances/child1 OSGi Framework org.apache.felix.framework - 4.0.3.fuse-beta-7-052 JVM Java Virtual Machine Java HotSpot(TM) 64-Bit Server VM version 20.6-b01-415 Version 1.6.0_31 Vendor Apple Inc. Uptime 6 minutes Total compile time 24.048 seconds Threads Live threads 62 Daemon threads 43 Peak 287 Total started 313 Memory Current heap size 78,981 kbytes Maximum heap size 466,048 kbytes Committed heap size 241,920 kbytes Pending objects 0 Garbage collector Name = 'PS Scavenge', Collections = 11, Time = 0.271 seconds Garbage collector Name = 'PS MarkSweep', Collections = 1, Time = 0.117 seconds Classes Current classes loaded 5,720 Total classes loaded 5,720 Total classes unloaded 0 Operating system Name Mac OS X version 10.7.3 Architecture x86_64 Processors 2
Disconnecting from a remote console
logout
or press Ctrl+D at the prompt.
8.2.2. Connecting to a Fabric Container From another Fabric Container
Overview
Using the fabric:container-connect command
Example 8.5. fabric:container-connect Command Syntax
fabric:container-connect
{
-u username
} {
-p password
} {
containerName
}
-
-u username
- The username used to connect to the remote console. The default value is
admin
. -
-p password
- The password used to connect to the remote console. The default value is
admin
. -
containerName
- The name of the container.
Example 8.6. Connecting to a Remote Container
JBossFuse:karaf@root>fabric:container-connect -u admin -p admin containerName
shell:info
at the prompt. Information about the currently connected instance is returned, as shown in Example 8.7, “Output of the shell:info Command”.
Example 8.7. Output of the shell:info Command
Karaf Karaf version 2.3.0.fuse-71-044 Karaf home /Volumes/SAMSUNG/Programs/ESB/jboss-fuse-full-6.0.0.redhat-0XX Karaf base /Volumes/SAMSUNG/Programs/ESB/jboss-fuse-full-6.0.0.redhat-0XX/instances/child1 OSGi Framework org.apache.felix.framework - 4.0.3.fuse-71-044 JVM Java Virtual Machine Java HotSpot(TM) 64-Bit Server VM version 20.8-b03-424 Version 1.6.0_33 Vendor Apple Inc. Uptime 7 minutes Total compile time 5.336 seconds Threads Live threads 42 Daemon threads 31 Peak 96 Total started 123 Memory Current heap size 32,832 kbytes Maximum heap size 466,048 kbytes Committed heap size 104,960 kbytes Pending objects 0 Garbage collector Name = 'PS Scavenge', Collections = 7, Time = 0.063 seconds Garbage collector Name = 'PS MarkSweep', Collections = 1, Time = 0.060 seconds Classes Current classes loaded 4,019 Total classes loaded 4,019 Total classes unloaded 0 Operating system Name Mac OS X version 10.7.4 Architecture x86_64 Processors 2
Disconnecting from a remote console
logout
or press Ctrl+D at the prompt.
8.2.3. Connecting to a Container Using the Client Command-Line Utility
Using the remote client
InstallDir/bin
directory), as follows:
client
client -a 8101 -h hostname -u username -p password shell:info
-p
option, you will be prompted to enter a password.
admin
privileges.
admin
and admin
.
client --help
Example 8.8. Karaf Client Help
Apache Felix Karaf client -a [port] specify the port to connect to -h [host] specify the host to connect to -u [user] specify the user name -p [password] specify the password --help shows this help message -v raise verbosity -r [attempts] retry connection establishment (up to attempts times) -d [delay] intra-retry delay (defaults to 2 seconds) [commands] commands to run If no commands are specified, the client will be put in an interactive mode
Disconnecting from a remote client console
8.2.4. Connecting to a Container Using the SSH Command-Line Utility
Overview
ssh
command-line utility (a standard utility on UNIX-like operating systems) to log in to the Red Hat JBoss Fuse container, where the authentication mechanism is based on public key encryption (the public key must first be installed in the container). For example, given that the container is configured to listen on TCP port 8101, you could log in as follows:
ssh -p 8101 jdoe@localhost
Prerequisites
- The container must be standalone (Fabric is not supported) with the
PublickeyLoginModule
installed. - You must have created an SSH key pair (see the section called “Creating a new SSH key pair”).
- You must install the public key from the SSH key pair into the container (see the section called “Installing the SSH public key in the container”).
Default key location
ssh
command automatically looks for the private key in the default key location. It is recommended that you install your key in the default location, because it saves you the trouble of specifying the location explicitly.
~/.ssh/id_rsa ~/.ssh/id_rsa.pub
C:\Documents and Settings\Username\.ssh\id_rsa C:\Documents and Settings\Username\.ssh\id_rsa.pub
Creating a new SSH key pair
ssh-keygen
utility. Open a new command prompt and enter the following command:
ssh-keygen -t rsa -b 2048
Generating public/private rsa key pair. Enter file in which to save the key (/Users/Username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Installing the SSH public key in the container
InstallDir/etc/keys.properties
file. Each user entry in this file appears on a single line, in the following format:
Username=PublicKey,Role1,Role2,...
~/.ssh/id_rsa.pub
, has the following contents:
ssh-rsa AAAAB3NzaC1kc3MAAACBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7 gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnfqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAAAAFQCX YFCPFSMLzLKSuYKi64QL8Fgc9QAAAnEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6Ewo FhO3zwkyjMim4TwWeotifI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoAAACB AKKSU2PFl/qOLxIwmBZPPIcJshVe7bVUpFvyl3BbJDow8rXfskl8wO63OzP/qLmcJM0+JbcRU/53Jj7uyk31drV2qxhIOsLDC9dGCWj4 7Y7TyhPdXh/0dthTRBy6bqGtRPxGa7gJov1xm/UuYYXPIUR/3x9MAZvZ5xvE0kYXO+rx jdoe@doemachine.local
jdoe
user with the admin
role by adding the following entry to the InstallDir/etc/keys.properties
file (on a single line):
jdoe=AAAAB3NzaC1kc3MAAACBAP1/U4EddRIpUt9KnC7s5Of2EbdSPO9EAMMeP4C2USZpRV1AIlH7WT2NWPq/xfW6MPbLm1Vs14E7 gB00b/JmYLdrmVClpJ+f6AR7ECLCT7up1/63xhv4O1fnfqimFQ8E+4P208UewwI1VBNaFpEy9nXzrith1yrv8iIDGZ3RSAHHAAAAFQCX YFCPFSMLzLKSuYKi64QL8Fgc9QAAAnEA9+GghdabPd7LvKtcNrhXuXmUr7v6OuqC+VdMCz0HgmdRWVeOutRZT+ZxBxCBgLRJFnEj6Ewo FhO3zwkyjMim4TwWeotifI0o4KOuHiuzpnWRbqN/C/ohNWLx+2J6ASQ7zKTxvqhRkImog9/hWuWfBpKLZl6Ae1UlZAFMO/7PSSoAAACB AKKSU2PFl/qOLxIwmBZPPIcJshVe7bVUpFvyl3BbJDow8rXfskl8wO63OzP/qLmcJM0+JbcRU/53Jj7uyk31drV2qxhIOsLDC9dGCWj4 7Y7TyhPdXh/0dthTRBy6bqGtRPxGa7gJov1xm/UuYYXPIUR/3x9MAZvZ5xvE0kYXO+rx,admin
id_rsa.pub
file here. Insert just the block of symbols which represents the public key itself.
Checking that public key authentication is supported
jaas:realms
console command, as follows:
Index Realm Module Class 1 karaf org.apache.karaf.jaas.modules.properties.PropertiesLoginModule 2 karaf org.apache.karaf.jaas.modules.publickey.PublickeyLoginModule
PublickeyLoginModule
is installed. With this configuration you can log in to the container using either username/password credentials or public key credentials.
Logging in using key-based SSH
$ ssh -p 8101 jdoe@localhost _ ____ ______ | | _ \ | ____| | | |_) | ___ ___ ___ | |__ _ _ ___ ___ _ | | _ / _ \/ __/ __| | __| | | / __|/ _ \ | |__| | |_) | (_) \__ \__ \ | | | |_| \__ \ __/ \____/|____/ \___/|___/___/ |_| \__,_|___/\___| JBoss Fuse (6.2.1.redhat-084) http://www.redhat.com/products/jbossenterprisemiddleware/fuse/ Hit '<tab>' for a list of available commands and '[cmd] --help' for help on a specific command. Hit '<ctrl-d>' or 'osgi:shutdown' to shutdown JBoss Fuse. JBossFuse:karaf@root>
ssh
utility will prompt you to enter the pass phrase.